2014年8月30日星期六

[UVa] 445 - Marvelous Mazes

#include <stdio.h>
#include <string.h>
int main(){
  char input;
  int count=0;
  while(1){
    input = getc(stdin);
    if(input==EOF)break;
 if(input>=48&&input<=57)count += input-48; //0~9
 else if(input=='!'||input=='\n')printf("\n"); //換行
 else
   while(count>0){  //根據先前累積的總和來決定輸出次數
     if(input=='b')printf(" "); //如果是b輸出空白
   else printf("%c",input);  //輸出原字元
  count--; 
   }
  }
} 

沒有留言: