uva 488 Triangle Wave

Triangle WaveTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmitStatus Practice UVA 488Appoint description:
Description
Download as PDF

**[Triangle Wave](http://acm.hust.edu.cn/vjudge/contest/view.action?cid=109419)**

In this problem you are to generate a triangular wave form according to a specified pair of Amplitude and Frequency.

Input and Output

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.

Each input set will contain two integers, each on a separate line. The first integer is the Amplitude; the second integer is the Frequency.

For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.

For the output of your program, you will be printing wave forms each separated by a blank line. The total number of wave forms equals the Frequency, and the horizontal ``height'' of each wave equals the Amplitude. The Amplitude will never be greater than nine.

The waveform itself should be filled with integers on each line which indicate the ``height'' of that line.

NOTE: There is a blank line after each separate waveform, excluding the last one.

Sample Input

1

3
2

Sample Output

1
22
333
22
1

1
22
333
22
1

uva 488 Triangle Waveuva 488 Triangle Wave

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
        while(n--)
        {
                int amp,fre;
                cin>>fre>>amp;
                //cout<<endl;
                for(int i=0;i<amp;i++)
                {
                    for(int j=1;j<=fre;j++)
                    {
                        int t=j;
                        while(t--) cout<<j;
                        cout<<endl;
                    }
                    for(int j=fre-1;j>=1;j--)
                    {
                        int t=j;
                        while(t--) cout<<j;
                        cout<<endl;
                    }
                    //cout<<"n="<<n<<endl;
                    //cout<<"sss";
                    if(i<amp-1)cout<<endl;
                }
                if(n>0) cout<<endl;
        }
    return 0;
}

View Code
主要是读懂题目的输出格式,每组测试样例之间要有空格,除了最后一组波外,每个波之间要有空行。
原文链接: https://www.cnblogs.com/superxuezhazha/p/5294889.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/230437

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月13日 下午2:41
下一篇 2023年2月13日 下午2:41

相关推荐