fjxmlhx不喜欢网上的 marshtomps 。所以他决定把所有的 “marshtomp”(名字不区分大小写) 改为 “fjxmlhx;
Input输入包含多行,每行字符串不超过200的长度,一个单词不会一半出现在上一行,剩下的在下一行。直到文件结束(EOF)
Output输出 替换之后的字符串。
Sample InputThe Marshtomp has seen it all before. marshTomp is beaten by fjxmlhx! AmarshtompBSample Output
The fjxmlhx has seen it all before. fjxmlhx is beaten by fjxmlhx! AfjxmlhxB
#include<stdio.h>
#include<string.h>
int main()
{
int i,l;
char s[201];
while(gets(s) != NULL)
{
l = strlen(s);
for (i=0;i<l;i++)
if ((s[i]=='m'||s[i]=='M')&&(s[i+1]=='a'||s[i+1]=='A')
&&(s[i+2]=='r'||s[i+2]=='R')&&(s[i+3]=='s'||s[i+3]=='S')
&&(s[i+4]=='h'||s[i+4]=='H')&&(s[i+5]=='t'||s[i+5]=='T')
&&(s[i+6]=='o'||s[i+6]=='O')&&(s[i+7]=='m'||s[i+7]=='M')
&&(s[i+8]=='p'||s[i+8]=='P'))
{
i+=8; //此处容易出错+9
printf("fjxmlhx");
}
else
printf("%c",s[i]);
printf("\n");
}
return 0;
}