遇到每個數字是"加起來",如23X,則輸出5個X,2X12*,則輸出XX***,b表示空格,!則要換行。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
沒有留言:
張貼留言