标签:
1 /* 2 * Author: Quickgrid ( Asif Ahmed ) 3 * Site: https://quickgrid.wordpress.com 4 * Problem: UVA 488 ( Triangle Wave ) 5 */ 6 #include<stdio.h> 7 8 /* For this problem amplitude does not exceed 9, so you can cheat <span class="wp-smiley wp-emoji wp-emoji-smile" title=":)">:)</span> */ 9 const char *a[] = {"", "1", "22", "333", "4444", "55555", "666666", "7777777", "88888888", "999999999"}; 10 11 int main(){ 12 register unsigned n, i, j, k; 13 scanf("%u", &n); 14 15 while(n--){ 16 unsigned amp, times; 17 scanf("%u%u", &, ×); 18 19 while(times--){ 20 for(i = 1; i < amp; ++i) 21 /* Just print the predefined strings */ 22 printf("%s\n", a[i]); 23 24 for(k = i; k; --k) 25 printf("%s\n", a[k]); 26 27 if(times || n) 28 printf("\n"); 29 } 30 } 31 return 0; 32 }
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 using namespace std; 5 6 const string a[] = {"", "1", "22", "333", "4444", "55555", "666666", "7777777", "88888888", "999999999"}; 7 8 int main() 9 { 10 register unsigned n, i, j, k; 11 string output, total = ""; 12 scanf("%u", &n); 13 14 while(n--) 15 { 16 unsigned amp, times; 17 scanf("%u%u", &, ×); 18 output = ""; 19 20 while(times--) 21 { 22 for(i=1; i<amp; ++i) 23 output += a[i] + "\n"; 24 for(k=i; k; --k) 25 output += a[k] + "\n"; 26 27 if(times || n) 28 output += "\n"; 29 } 30 total += output; 31 } 32 33 cout << total; 34 return 0; 35 }
标签:
原文地址:http://www.cnblogs.com/aze-003/p/5092864.html