标签:style blog io color ar os for sp strong
描述
编写一个程序实现将字符串中的所有"you"替换成"we"
you are what you do
we are what we do
#include<iostream> #include<string> using namespace std; int main() { string arr; int m ; while( getline(cin,arr) && !cin.eof()) { m = arr.length(); for(int i=0;i<m;i++) { if(arr[i]==‘y‘&&arr[i+1]==‘o‘&&arr[i+2]==‘u‘) { cout<<"we"; i +=2; } else cout<<arr[i]; } cout<<endl; } return 0; }
标签:style blog io color ar os for sp strong
原文地址:http://www.cnblogs.com/imwtr/p/4069511.html