Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char st[100];
  8. int l = 0;
  9. gets_s(st);
  10. int n = strlen(st);
  11. if (st[n - 1] == '1') st[n] = '0';
  12. else st[n] = '1';
  13. cout << endl;
  14. if (n < 2) return 1;
  15.  
  16. for (int i = 0; i < n; i++)
  17. {
  18. if (st[i] != st[i + 1]) {
  19. if (((i - l) + 1) % 2 == 0){
  20. for (int j = l; j < i + 1; j++) {
  21. cout << st[i] << " ";
  22. }
  23. cout << endl;
  24. }
  25. l = i+1;
  26. }
  27. }
  28. system("pause");
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement