• uva 488 Triangle Wave


    Triangle Wave
    Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu
    Appoint description: 

    Description

    Download as PDF
     

     

     Triangle Wave 

    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
    #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

    主要是读懂题目的输出格式,每组测试样例之间要有空格,除了最后一组波外,每个波之间要有空行。

  • 相关阅读:
    VS2008正式版序列号
    清空SQL Server数据库中所有的用户表
    [原创]JavaScript调用Button的服务器端事件
    动态加载枚举 到 DropdownList
    [转载]静态构造函数
    SQL 事务 [两种]
    Jpg文件格式[参考]
    Delegate Event
    javascript 操作cookie类
    [共享]一个文件上传的控件,绝对是精品源码
  • 原文地址:https://www.cnblogs.com/superxuezhazha/p/5294889.html
Copyright © 2020-2023  润新知