joj2471
2011-08-29 08:59
260 查看
2471: String triangle
Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
---|---|---|---|---|---|
3s | 65536K | 3037 | 604 | Standard |
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;
}
相关文章推荐
- joj 儿死三八
- JOJ 1903 1129 1157 1278
- JOJ 1065: Truck Driver 解题报告
- joj 1026: The Staircases
- joj 1020 格式输出
- joj2697
- joj 2699: 16 and 18 博弈 最后一个取石子者输
- joj 1173
- joj 2736: 二叉树计数 卡特兰数取模 1<=n<=10^9,1<=m<=32768
- joj 1509Hamiltonian Cycle (dfs求H回路)
- joj 2426
- joj1059
- joj2218
- JOJ 2580 Welcome to JL2009
- JOJ1871:Jogging Trails
- joj 2699
- JOJ1874:Relatives
- joj1966
- JOJ 1007解题
- joj 1008 Go hang a salami 回文判断