Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- const int XL = 50;
- int main()
- {
- int n,q=0; cin >> n;
- char k;
- char a[XL];
- char b[XL];
- cin >> a;
- for(int i =0; i < n-1; i++)
- {
- if (a[i+1] != k)
- {
- k = 0;
- }
- if (a[i] == a[i+1]|| a[i+1] == k)
- {
- k = a[i+1];
- a[i+1] = '0';
- }
- }
- for(int i =0; i < n; i++)
- {
- if(a[i] == '0')
- {
- q++;
- }
- }
- cout << endl << endl;
- for(int i =0; i < n; i++)
- {
- cout << a[i];
- }
- cout << endl << endl;
- cout << q;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement