UVa 488 - Triangle Wave

时间:2022-05-28 07:44:55

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=429

题目:每个例子输入2个数,一个是wave的幅度,一个是重复的个数。

例如:
Input
1 3
2 output:
1
22
333
22
1 1
22
333
22
1

思路: 将1,22,333,···,999999999.字符串存在数组里。按照幅度打印输出就好。然后注意一下空行。

 #include<iostream>
#include<cstdio>
using namespace std; char cc[][]={"","","","","","","","",""}; int main()
{
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
int t,n,m,i,j,k;
cin>>t;
while(t--)
{
cin>>n>>m;
for(i=;i<m;i++)
{
for(j=;j<n;j++)
cout<<cc[j]<<'\n';
for(j=n-;j>=;j--)
cout<<cc[j]<<'\n';
if(i<m-)
cout<<'\n';
}
if(t>)
cout<<'\n'; }
return ;
}