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;
}
原文地址:https://www.cnblogs.com/slothrbk/p/7251870.html