标签:
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main(){
string str,s;
cin>>str;
int m = str.length();
vector<string> v;
for(int i = 0 ; i < m;++i){
if(i + 2 < m && str[i] == ‘W‘ && str[i + 1] == ‘U‘ && str[i + 2] == ‘B‘){
i += 2;
if(s != ""){
v.emplace_back(s);
s = "";
}
}else s += str[i];
}
if(s != ""){
v.emplace_back(s);
s = "";
}
m = v.size();
for(int i = 0 ;i < m - 1 ;++i){
cout<<v[i]<<‘ ‘;
}
cout<< v[m - 1] <<‘\n‘;
return 0;
}
#include <cstdio>
#include<cstring>
using namespace std;
char str[200 + 10];
int main(){
gets(str);
int m = strlen(str),cur = 0,flg = 0;
for(int i = 0; i < m ;++i){
if(i + 2 < m && str[i] == ‘W‘ && str[i + 1] == ‘U‘ && str[i + 2] == ‘B‘){
i += 2;
if(flg) str[cur++] = ‘ ‘;
}else {
str[cur++] = str[i];
flg = 1;
}
}
str[cur] = ‘\0‘;
printf("%s\n",str);
return 0;
}
[2016-03-23][codeforces][208][A][Dubstep]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/fdd1b4cee783d7e386a135199a5fb56f.html