标签:
PS:The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.
Sample Input
3
2
Sample Output
1
22
333
22
1
1
22
333
22
1
Language:C++ 4.8.2
#include<stdio.h>
int main(void)
{
int m, n, total;
int copy_i;
scanf("%d", &total);
while(total--)
{
scanf("%d%d", &m, &n);
while(n--)
{
for(int i = 1; i <= m; i++)
{
copy_i = i;
while(copy_i--)
printf("%d", i);
printf("\n");
}
for(int i = m-1; i >=1; i--)
{
copy_i = i;
while(copy_i--)
printf("%d", i);
printf("\n");
}
if(n) // there is a blank line after each separate waveform, excluding the last one.
printf("\n");
}
if(total) // 同上,缺少的话WA。
printf("\n");
}
return 0;
}
// 再PS:该题关键是格式,每两组之间两个空行,单组之内的三角波之间有一个空行。
标签:
原文地址:http://www.cnblogs.com/xpjiang/p/4388431.html