2014年8月12日星期二

[UVa] 488 - Triangle Wave


#include <stdio.h>
#include <stdlib.h>
int c; /*case*/
int i,j,tmp;
int main(){
   scanf("%d",&c); /*輸入case數*/
   int S[2][c]; /*宣告 case * 2 的矩陣,擺放每個case的Amplitude及Frequency值*/    
   for(i=0;i<c;i++){
      scanf("%d%d", &S[0][i], &S[1][i]);
      while(S[1][i]>0){
    for(j=1 ; j<=S[0][i] ; j++){
    for(tmp=0; tmp<j; tmp++)
    printf("%d",j);
    printf("\n");
    }
    for(j=S[0][i]-1 ; j>0 ; j--){       
    for(tmp=0; tmp<j; tmp++)
    printf("%d",j);
    printf("\n");
    }
    S[1][i]--;
    if(S[1][i]>0)printf("\n");
      }
   if(i<(c-1))printf("\n");
   }
   return 0;
}

沒有留言: