joj2471

2471: String triangle


Result TIME Limit MEMORY Limit Run Times AC Times JUDGE
3s 65536K 3073 611 Standard

You are asked to draw a right-angle triangle, the given materials is a special word. Just see the sample for detail.

Input

The first line of each test case is a positive integer n. n is zero means the end of input that you should not care. The next line is a word (no blank) whose length is no more than 80.

Output

Print a right-angle triangle whose height and width are n using given word. You should print each character in the word in turn, if the last character is used, the next is the first character. Print a blank line between each case.

Sample Input

6

WORLD

3

ABCD

0

Sample Output

W

OR

LDW

ORLD

WORLD

WORLDW



A

BC

DAB

Problem Source: skywind

 


This problem is used for contest: 101 157 168 179


Submit / Problem List / Status / Discuss

 

 

#include<stdio.h>

int main(void)
{
int n;
char a[100];
bool first = false;
while(scanf("%d",&n), n)
{
if (first) //注意题目的格式
printf("\n");
first = true;

scanf("%s", a);

char * p = a;

for(int i=1; i<=n; i++)
{
for(int j=1; j<=i; j++)
{
if (*p == '\0')
p = a;
printf("%c", *p);
p++;
}
printf("\n");
}
}
return 0;
}

 

你可能感兴趣的:(OJ)