| |||||
Description | |||||
fjxmlhx每天都在被沼跃鱼刷屏,因此他急切的找到了你希望你写一个程序屏蔽所有句子中的沼跃鱼(“marshtomp”,不区分大小写)。 | |||||
Input | |||||
输入包括多行。每行是一个字符串,长度不超过200。 一行的末尾与下一行的开头没有关系。 | |||||
Output | |||||
输出包含多行,为输入按照描述中变换的结果。 | |||||
Sample Input | |||||
The Marshtomp has seen it all before. marshTomp is beaten by fjxmlhx! AmarshtompB | |||||
Sample Output | |||||
The fjxmlhx has seen it all before. fjxmlhx is beaten by fjxmlhx! AfjxmlhxB | |||||
Hint | |||||
不存在mar shto mp这种用空格分开的情况。 有可能一个句子中有两个以上“marshtomp”。 |
这道题目就是题目没给出有多少行,所以用cin.getline()这个输入函数,贴代码:
<span style="font-size:14px;">#include<string>
#include<sstream>
#include<iostream>
using namespace std;
int main()
{
char c[250],a[250];
int stl,i,j;
while(cin.getline(c,250))
{
strcpy(a,c);
//puts(d);
stl=strlen(c);
for(i=0;i<stl;i++)
{
a[i]=tolower(a[i]);
}
for(i=0;i<stl;i++)
{
if(a[i]=='m'&&a[i+1]=='a'&&a[i+2]=='r'&&a[i+3]=='s'&&a[i+4]=='h'&&a[i+5]=='t'&&a[i+6]=='o'&&a[i+7]=='m'&&a[i+8]=='p')
{
printf("fjxmlhx");i=i+8;
}
else
{
printf("%c",c[i]);
}
}
printf("\n");
}
} </span>