题目描述
给定一个短字符串(不含空格),再给定若干字符串,在这些字符串中删除所含有的短字符串。
输入
输入只有1组数据。
输入一个短字符串(不含空格),再输入若干字符串直到文件结束为止。
输出
删除输入的短字符串(不区分大小写)并去掉空格,输出。
样例输入
in
#include
int main()
{
printf(" Hi ");
}
样例输出
#clude
tma()
{
prtf("Hi");
}
提示
注:将字符串中的In、IN、iN、in删除。
#include <cstdio>
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
const int maxn=205;
char s[maxn];
int main(){
gets(s);
string a=s;
for(int i=0;i<a.size();i++) a[i]=tolower(a[i]);
while(gets(s)){
string b=s,c=b;
for(int i=0;i<b.size();i++) b[i]=tolower(b[i]);
int t=b.find(a,0);
while(t!=string::npos){
c.erase(t,a.size());
b.erase(t,a.size());
t=b.find(a,t);
}
t=c.find(' ',0);
while(t!=string::npos){
c.erase(t,1);
t=c.find(' ',0);
}
cout<<c<<endl;
}
return 0;
}