網頁

2014年2月3日 星期一

UVa 445 Marvelous Mazes

題意:
  遇到每個數字是"加起來",如23X,則輸出5個X,2X12*,則輸出XX***,b表示空格,!則要換行。



#include <cstdio>
using namespace std;
int main()
{
// freopen ("input.txt","rt",stdin);
char c;
int num=0;
while (c=getchar()){
if (c == EOF) break;
if (c == '\n' || c == '!')
printf("\n");
else if (c >= '0' && c <= '9')
num += (c - '0');
else{
if (c == 'b'){
for (int i=0; i<num; i++)
printf(" ");
}
else {
for (int i=0; i<num; i++)
printf("%c",c);
}
num = 0;
}
}
return 0;
}

沒有留言:

張貼留言