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", &, &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", &, &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