http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1184
给定原字符串,和需要删掉的字符串集,然后输出删除后的字符串,如果长度变为0,输出LOSER。
考验编码能力 !!
#include<cstdio> #include<string> #include<iostream> using namespace std; char ss[10][10]={"HATE","SHIT","LV","O","FUCK","UGLY","MM"}; int dit[10]={4,4,2,1,4,4,2}; string s; string jiesu(string s) { string s1=""; for(int i=0;i<s.size();i++) if(s[i]!='#') s1+=s[i]; return s1; } bool solve() { int flag=0; for(int i=0;i<7;i++) { int t=-1; t=s.find(ss[i]); if(t!=-1) { flag=1; for(int j=t;j<t+dit[i];j++) s[j]='#'; } } s=jiesu(s); return flag; } int main() { while(cin>>s) { while(solve()); if(s.size()) cout<<s<<endl; else cout<<"LOSER\n"; } return 0; }
时间: 2024-11-06 11:51:27