【 POJ - 3981 】A - 字符串替换 (字符串水题)

代码:

#include
#include
#include 
using namespace std;
typedef long long ll;
int main()
{
	string s,x;
	while(getline(cin,s))
	{
		stringstream ss(s); //放入字符串流中
		while(ss>>x)
		{
			if(x=="you") cout<<"we"<<" "; //将you替换为we即可
			else cout<<x<<" ";
		}
		cout<<endl;
	}
    return 0;
}

你可能感兴趣的:(算法,字符串,c++,poj)