2017年4月6日 星期四

Uva 488 Triangle Wave - 參考答案

Difficulty: Eazy
Ref: UVa Online Judge - Uva 488 Triangle Wave
/*******************************************************/
/* UVa 488 - Traingle Wave                             */
/* Author: awei0905  [at]  awei0905.blogspot.tw        */
/* Version: 2017/04/06                                 */
/*******************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main() {
 int n, height, times;
 scanf("%d", &n);
 while (n-- > 0 && scanf("%d%d", &height, &times) != EOF) {
  while (times--) {
   for (int i = 1; i <= height; i++) {
    for (int j = 0; j < i; j++)
     printf("%d", i);
    printf("\n");
   }
   for (int i = height - 1; i >= 1; i--) {
    for (int j = 0; j < i; j++)
     printf("%d", i);
    printf("\n");
   }
   if (times) printf("\n");
  }
  if (n) printf("\n");
 }
}
Debug: I/O, uDebug
2

2
2

3
1
1
22
1

1
22
1

1
22
333
22
1

沒有留言:

張貼留言