题目:每个例子输入2个数,一个是wave的幅度,一个是重复的个数。
例如:Input1 32 output:122333221 122333221
思路: 将1,22,333,···,999999999.字符串存在数组里。按照幅度打印输出就好。然后注意一下空行。
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 char cc[9][10]={"1","22","333","4444","55555","666666","7777777","88888888","999999999"}; 6 7 int main() 8 { 9 // freopen("input.txt","r",stdin); 10 // freopen("output.txt","w",stdout); 11 int t,n,m,i,j,k; 12 cin>>t; 13 while(t--) 14 { 15 cin>>n>>m; 16 for(i=0;i<m;i++) 17 { 18 for(j=0;j<n;j++) 19 cout<<cc[j]<<‘\n‘; 20 for(j=n-2;j>=0;j--) 21 cout<<cc[j]<<‘\n‘; 22 if(i<m-1) 23 cout<<‘\n‘; 24 } 25 if(t>0) 26 cout<<‘\n‘; 27 28 } 29 return 0; 30 }
时间: 2024-09-30 07:23:27