you are what you do
we are what we do
#include <iostream> #include <string> using namespace std; int main(){ string str; while(getline(cin,str)){ int pos = 0; while((pos = str.find("you",pos))!=string::npos){ str.replace(str.begin()+pos,str.begin()+pos+3,"we"); pos =pos+3; } cout<<str<<endl; } }
原文:http://www.cnblogs.com/xiongqiangcs/p/3642813.html