标签:style blog class code java color
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> using namespace std; const int M=1000; int main() { string china; int a[M]={-1},b[M]={-1},i,indexa,indexb,len,m; len=strlen("你"); //freopen("637.in","r",stdin); //freopen("637.out","w",stdout); cin>>china; while(china!="0") { m=china.length(); for(i=0;i<m;i++) { a[i]=b[i]=-1; } indexa=indexb=0; while(true) { indexa=china.find("我",indexa); if(indexa==string::npos) break; a[indexa]=1; indexa++; } while(true) { indexb=china.find("你",indexb); if(indexb==string::npos) break; b[indexb]=1; indexb++; } for(i=0;i<m;i++) { if(a[i]==1) { china.replace(i,len,"你"); } if(b[i]==1) { china.replace(i,len,"我"); } } cout<<china<<endl; cin>>china; } return 0; }
标签:style blog class code java color
原文地址:http://www.cnblogs.com/jianfengyun/p/3716610.html