Advertisement
Guest User

lab 4

a guest
Apr 5th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1.  
  2.  
  3. #include <iostream>
  4. #include <string>
  5. int main()
  6. {  
  7.     using namespace std;
  8.     string input; int s=0, index=NULL;
  9.     cin >> input;
  10.     for (int i = 0; i < input.size(); i++) {
  11.         if (input[i] == input[i + 1]) {
  12.             s++;
  13.             if (index == NULL) {
  14.                 index = i + 1;
  15.             }
  16.         }
  17.     }
  18.     input.erase(index, s);
  19.     input.insert(index, 1, char(s+49));
  20.     cout << input;
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement