Triangle Wave

原创 2013年12月04日 20:37:01
 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 <stdio.h>

int main()
{
    int t, m, n, x, z, i, j, k, h;
    scanf("%d", &t);
    for(i = 0; i < t; i++)
    {
        scanf("%d%d", &m, &n);
        for(j = 0; j < n; j++)
        {
            for(k = -m + 1; k < m; k++)
            {
                z = k > 0 ? k : -k;
                for(h = 1; h <= m - z; h++)
                {
                    printf("%d", m - z);
                }
                printf("\n");
            }
            if(j != n - 1 || i != t - 1)
                printf("\n");
        }
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

UVA - 488 Triangle Wave(水题)

Triangle Wave  In this problem you are to generate a triangular wave form according to a spec...

488 - Triangle Wave

Triangle Wave  In this problem you are to generate a triangular wave form according to a spec...

精选:深入理解 Docker 内部原理及网络配置

网络绝对是任何系统的核心,对于容器而言也是如此。Docker 作为目前最火的轻量级容器技术,有很多令人称道的功能,如 Docker 的镜像管理。然而,Docker的网络一直以来都比较薄弱,所以我们有必要深入了解Docker的网络知识,以满足更高的网络需求。

UVa488 Triangle Wave

Triangle Wave  In this problem you are to generate a triangular wave form according to a sp...

UVA oj 488 Triangle Wave

Triangle Wave Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu...

UVa 488 Triangle Wave (water ver.)

488 - Triangle Wave Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_online...

【UVA】【第0章】488 - Triangle Wave

Triangle Wave  In this problem you are to generate a triangular wave form according to a specified ...

UVa 488 Triangle Wave(三角波)

Triangle Wave  In this problem you are to generate a triangular wave form according to a specifi...

UVA 488 Triangle Wave(输出三角波)

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

波的衍射

人们为了分析波的衍射现象,构造了许多数学模型,其中包括从波动方程推导出的菲涅耳-基尔霍夫衍射公式、夫琅禾费衍射模型以及菲涅耳衍射模型。[24]:198-200设为圆孔半径或狭缝宽度,为入射波的波长,为...

ADPCM与PCM的区别 以及wave文件的压缩与解压缩

http://blog.csdn.net/kindyb/archive/2005/10/13/503024.aspx 一、概述:   本文叙述了如何通过IMA-ADPCM压缩和解压缩算法来...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)