标签:pre string clu ++ ipo 思考 pac for else
水题 :
思考含量不大,看看就ok
#include <bits/stdc++.h>
using namespace std;
int ilen=1,ipos=0;
int main()
{
string s;
cin>>s;
int len=s.length();
for(int i=0;i<len;i++)
{
ilen=1;
ipos=i;
while(s[i]==s[i+1])
{
ilen++;
i++;
}
if(ilen<=1)
continue;
if(ilen%2==0)
for(int j=ipos;j<ipos+ilen&&j<len;j+=2)
{
s[j]=‘a‘;
while(s[j]==s[j-1]||s[j]==s[j+1])
s[j]++;
}
else
for(int j=ipos+1;j<ipos+ilen&&j<len;j+=2)
{
s[j]=‘a‘;
while(s[j]==s[j-1]||s[j]==s[j+1])
s[j]++;}
}
cout<<s<<endl;
}
标签:pre string clu ++ ipo 思考 pac for else
原文地址:http://www.cnblogs.com/masterchd/p/7148230.html