Link:http://hihocoder.com/problemset/problem/1082
时间限制:
1000ms
单点时限:
1000ms
内存限制:
256MB
-
The Marshtomp has seen it all before. marshTomp is beaten by fjxmlhx! AmarshtompB
样例输出
-
The fjxmlhx has seen it all before. fjxmlhx is beaten by fjxmlhx! AfjxmlhxB
描述
fjxmlhx每天都在被沼跃鱼刷屏,因此他急切的找到了你希望你写一个程序屏蔽所有句子中的沼跃鱼(“marshtomp”,不区分大小写)。为了使句子不缺少成分,统一换成 “fjxmlhx” 。
输入
输入包括多行。
每行是一个字符串,长度不超过200。
一行的末尾与下一行的开头没有关系。
输出
输出包含多行,为输入按照描述中变换的结果。
AC code:
#include<iostream>
#include<stdio.h>
#include<map>
#include<vector>
#include<set>
#include<cstdlib>
#include<string.h>
#include<string>
#include<algorithm>
#include<cmath>
#define MAXN 1000010
#define EPS 1e-9
using namespace std;
char s[222];
char p[]="marshtomp";
char t[]="fjxmlhx";
int fg[222];
int main()
{
//freopen("in.txt","r",stdin);
int i,j,k;
while(gets(s))
{
int lens=strlen(s);
memset(fg,1,sizeof(fg));
for(i=0;i<=lens-9;i++)
{
for(j=i;j<i+9;j++)
{
if(tolower(s[j])!=p[j-i])
{
break;
}
}
if(j==i+9)
{
k=0;
for(;i<j-2;i++)
{
s[i]=t[k];
k++;
}
fg[i]=0;
fg[i+1]=0;
i++;
}
}
for(i=0;i<lens;i++)
{
if(fg[i])
{
printf("%c",s[i]);
}
}
puts("");
}
return 0;
}