UVA 488-triangle Wave

Source: Internet
Author: User

1 /*2 * Author:quickgrid (Asif Ahmed)3 * Site:https://quickgrid.wordpress.com4 * Problem:uva 488 (Triangle Wave)5  */6#include <stdio.h>7  8 /*for the problem amplitude does not exceed 9, so can cheat <span class= "Wp-smiley wp-emoji wp-emoji-smile" tit le= ":)" >:) </span>*/9 Const Char*a[] = {"","1"," A","333","4444","55555","666666","7777777","88888888","999999999"};Ten   One intMain () { A Register unsigned n, I, J, K; -scanf"%u", &n); -   the      while(n--){ - unsigned amp, times; -scanf"%u%u", &amp, &Times ); -   +          while(times--){ -              for(i =1; I < amp; ++i) +                 /*Just Print the predefined strings*/ Aprintf"%s\n", A[i]); at   -              for(k = i; k;--k) -printf"%s\n", A[k]); -   -             if(Times | |N) -printf"\ n"); in         } -     } to     return 0; +}
C

1#include <iostream>2#include <cstring>3#include <cstdio>4 using namespacestd;5 6 Const stringA[] = {"","1"," A","333","4444","55555","666666","7777777","88888888","999999999"};7 8 intMain ()9 {Ten Register unsigned n, I, J, K; One     stringOutput, total =""; Ascanf"%u", &n); -  -      while(n--) the     { - unsigned amp, times; -scanf"%u%u", &amp, &Times ); -Output =""; +         -          while(times--) +         { A              for(i=1; i<amp; ++i) atOutput + = A[i] +"\ n"; -              for(k=i; k;--k) -Output + = A[k] +"\ n"; -              -             if(Times | |N) -Output + ="\ n"; in         } -Total + =output; to     } +  -cout <<Total ; the     return 0; *}
C + +

Code Source

UVA 488-triangle Wave

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.