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;
}

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

Spark组件之GraphX学习14--TriangleCount实例和分析

更多代码请见:https://github.com/xubo245/SparkLearning 1解释 统计图中的Triangle,并返回 源码: /* * Licensed t...
  • bob601450868
  • bob601450868
  • 2016年05月04日 18:51
  • 1575

【LeetCode-面试算法经典-Java实现】【120-Triangle(三角形)】

【120-Triangle(三角形)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题  Given a triangle, find the minimum path sum...
  • DERRANTCM
  • DERRANTCM
  • 2015年08月14日 06:13
  • 2342

关于TRIANGLE二维三角网格生成器在windows下的配置说明

最近需要用到三角网格生成的一些东西,所以就把TRIANGLE这个库编译了一下,发现编译过程还是稍微有些纠结,于是就想到写下来,希望以后有些童鞋看到少走一些弯路。      首先非常感谢eryar的帮助...
  • shlkl99
  • shlkl99
  • 2014年06月18日 21:21
  • 1890

UVA 488 Triangle Wave(输出三角波)

Triangle Wave Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Sta ...
  • Hush_lei
  • Hush_lei
  • 2014年08月04日 14:01
  • 805

UVa 488 Triangle Wave (water ver.)

488 - Triangle Wave Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_online...
  • synapse7
  • synapse7
  • 2013年09月13日 23:28
  • 895

UVA oj 488 Triangle Wave

Triangle Wave Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu...
  • Sara_YF
  • Sara_YF
  • 2016年06月02日 12:51
  • 198

UVA - 488 Triangle Wave(水题)

Triangle Wave  In this problem you are to generate a triangular wave form according to a spec...
  • HelloWorld10086
  • HelloWorld10086
  • 2014年08月20日 20:06
  • 526

算法竞赛入门经典-前四章-UVa488 - Triangle Wave-三角波-难度1

题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=...
  • l_200691
  • l_200691
  • 2013年12月18日 22:08
  • 422

UVa488 Triangle Wave

Triangle Wave  In this problem you are to generate a triangular wave form according to a sp...
  • u010544342
  • u010544342
  • 2013年08月07日 08:49
  • 718

488 - Triangle Wave

Triangle Wave  In this problem you are to generate a triangular wave form according to a spec...
  • zhuyi2654715
  • zhuyi2654715
  • 2012年05月15日 14:40
  • 2137
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Triangle Wave
举报原因:
原因补充:

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