Language:C++ 4.8.2
#include<stdio.h> #include<string.h> #include<ctype.h> int main(void) { char str[140]; int sum; while(1) { if(fgets(str, sizeof(str), stdin) == NULL) break; if(str[0] == ‘\n‘) { printf("\n"); continue; } else // 处理读入行 { int i = 0; while(i < strlen(str)) { if(str[i] == ‘!‘) { printf("\n"); i++; } sum = 0; while(isdigit(str[i])) sum += str[i++] - ‘0‘; for(int j = 0; j < sum; j++) printf("%c", str[i] == ‘b‘ ? ‘ ‘ : str[i]); // 最好用if.else,懒得改了:- i++; // 缺少此行的话,该程序陷入死循环 } printf("\n"); } } return 0; }
时间: 2024-12-27 21:46:38