UVA 488 - Triangle Wave

题意:
第一行输入有n组数据
后面输入n行数据,每组数据包含一个振幅和重复次数
注意输出的最后一组数据后没有空行

代码如下:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        int a,b;
        cin>>a>>b;
        for(int i=1; i<=b; ++i)
        {
            for(int j=1; j<a; ++j)
            {
                for(int k=j; k; --k)
                    cout<<j;
                cout<<endl;
            }
            for(int j=a; j; --j)
            {
                for(int k=j; k; --k)
                    cout<<j;
                cout<<endl;
            }
            if((i-b)||n)
                cout<<endl;
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/liuxinyu666/article/details/80268380
今日推荐