Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t,cnt=0;
- cin>>t;
- char ch[t];
- for(int i=0;i<t;i++)
- {
- cin>>ch[i];
- }
- for(int i=0;i<t;i=i+2)
- {
- if(ch[i]=='a' && ch[i+1]!='b') {cnt ++;
- ch[i+1] = 'b';
- }
- if(ch[i]=='b' && ch[i+1]!='a') {cnt ++;
- ch[i+1] = 'a';
- }
- }
- cout<<cnt<<endl;
- for(int i=0;i<t;i++)
- {
- cout<<ch[i];
- }
- cout<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement