Uva488 triangle wave

Source: Internet
Author: User


In this problem you are to generate a triangular wave form according to a specified pair of amplency 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 amplency; 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 Amplications. the amplater will never be greater than nine.

The waveform itself shoshould be filled with integers on each line which indicate the ''height' of that line.

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

Sample Input

132
Sample output

122333221122333221

I haven't reviewed my questions for a long time. Today, I have to wait for a while. The output format is a little strange ~~
#include <stdio.h>void printTriangel(int m){int i, j;for(i = 1; i < m; ++i){for(j = 1; j <= i; ++j)printf("%d", i);printf("\n");}while(i >= 1){for(j = 1; j <= i; ++j)printf("%d", i);printf("\n");--i;}}int main(){int t, m, n;scanf("%d", &t);while(t--){scanf("%d%d", &m, &n);while(n--){printTriangel(m);if(t || n) putchar('\n');}}return 0;}



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.