Codeforces Round #130 (Div. 二) A. Dubstep(STL做法)

Codeforces Round #130 (Div. 2) A. Dubstep(STL做法)

找到所有的WUB
直接用空格代替即可
用string很方便

#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>

/*
int gcd(int a,int b)
{
    return ! b ? a : gcd(b,a % b);
}
bool cmp(const data &a,const data &b)
{
    if(a.val == b.val)
        return a.pos < b.pos;
    return a.val < b.val;
}
*/
typedef long long LL;

const double pi = acos(-1.0);
const long long mod = 1e9 + 7;

using namespace std;

string s;
int main()
{
    //freopen("int.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin >> s;
    int a = s.find("WUB");
    while(a != -1)
    {
        s.replace(a,3," ");
        a = s.find("WUB");
    }
    cout << s << endl;
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。