真是服了自己了,一个简单的字符串替换搞了半天……………………
C++还是不太会
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str;
while(getline(cin,str))
{
//getchar();
string::size_type pos = 0;
string str1="you";
while ((pos=str.find(str1,pos)) != string::npos)//若查找失败,返回string::npos
{
str.replace(pos,str1.size(),"we");
pos++;
}
cout<<str<<endl;
}
return 0;
}
转载于:https://www.cnblogs.com/nanke/archive/2011/07/30/2122008.html
相关资源:数据结构—成绩单生成器