NYOJ--113--字符串替换

/*
    Name: NYOJ--113--字符串替换
    Author: shen_渊 
    Date: 18/04/17 15:41
    Description: 字符串水题,秒过 
*/
#include<bits/stdc++.h> 
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    string str;
    const string syou = "you";
    const string swe = "we";
    while(getline(cin,str)){
        int pos;
        while((pos = str.find(syou)) != string::npos){
            str.erase(pos,3);
            str.insert(pos,swe);
        }
        cout<<str<<endl;
    }
    return 0;
}

 

posted @ 2017-04-18 15:42  朤尧  阅读(256)  评论(0编辑  收藏  举报