码迷,mamicode.com
首页 > 其他好文 > 详细

UVa 488 - Triangle Wave

时间:2016-08-04 01:21:39      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:

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.字符串存在数组里。按照幅度打印输出就好。然后注意一下空行。

 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 }     

 

UVa 488 - Triangle Wave

标签:

原文地址:http://www.cnblogs.com/aiheshan/p/5735007.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!