UVa 488 triangle Wave (water ver.)

Source: Internet
Author: User
Tags time limit

488-triangle Wave

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem &problem=429

In this problem your 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 in a line by itself indicating the number of cases following, each of them as described below. This are followed by a blank line, and there are also a blank line between two consecutive.

Each input set would contain two integers, each in a separate line. 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 is separated by a blank line.

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

The waveform itself should is filled with integers on each line which indicate the ' height ' of this line.

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

Sample Input

1

3
2

Sample Output

1
333
1

1
333
1

Complete code:

/*0.065s*/
  
#include <cstdio>
  
int main (void)
{
    int T, A, F;
    int I, j, K, L;
    scanf ("%d", &t);
    for (i = 0; i < T; i++)
    {
        if (i)
            putchar (' \ n ');
        scanf ("%d%d", &a, &f);
        for (j = 0; J < F; J +)
        {
            if (j)
                Putchar (' \ n ');
            for (k = 0; k < A; k++)
            {for
                (l = 0; l <= k; l++)
                    Putchar (' 1 ' + K);
                Putchar (' \ n ');
            }
            for (k = A-2 k >= 0; k--)
            {for
                (l = 0; l <= k; l++)
                    Putchar (' 1 ' + K);
                Putchar (' \ n ')
            ;
    }} return 0;
}

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.