您的位置:首页 > 其它

joj2471

2011-08-29 08:59 260 查看




2471: String triangle

ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE

3s65536K3037604Standard
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

Problem Set with Online Judge System Version 3.12

Jilin University

Developed by skywind,
SIYEE

#include<cstdio>

int main()

{

//freopen("in.txt","r",stdin);

//freopen("out.txt","w",stdout);

int n;

char a[88];

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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: