要求:
http://codeup.cn/problem.php?cid=100000580&pid=4
说明:
特别特别强调,对于字符串和字符的输入,%s通过空格和换行来识别一个字符串的结束,%c是可以匹配空格的;gets识别换行符作为输入结束
代码:
#include <stdio.h>
#include <string.h>
struct code{
int len;
char str[210];
char c;
}record[1000];
int main(){
int signal = 0;
while(gets(record[signal].str)){
record[signal].len = strlen(record[signal].str);
scanf("%c",&(record[signal].c));
signal++;
//最后必须加一个getchar(),否则要输两次Ctrl+Z才能结束
getchar();
}
for(int i = 0;i <signal;i++){
for(int j = 0;j <record[i].len;j++){
if(record[i].str[j]== record[i].c){
printf("");
}
else{
printf("%c",record[i].str[j]);
}
}
printf("\n");
}
}