View Code of Problem 3496

#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cctype>
using namespace std;
int main()
{
	string str,s1="you",s2="we";
	while( getline(cin,str) ){
		int i=0,pos;
		while( str.find(s1,i)!=-1 ){
			pos=str.find(s1,i);
			str.replace(pos,s1.length(),s2);
			i=pos+2;
//			cout<<"i="<<i<<endl;
		}
		cout<<str<<endl;
	} 
}

Double click to view unformatted code.


Back to problem 3496