Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5. const int XL = 50;
  6. int main()
  7. {
  8.  
  9. int n,q=0; cin >> n;
  10. char k;
  11.  
  12. char a[XL];
  13. char b[XL];
  14.  
  15. cin >> a;
  16.  
  17. for(int i =0; i < n-1; i++)
  18. {
  19. if (a[i+1] != k)
  20. {
  21. k = 0;
  22. }
  23.  
  24. if (a[i] == a[i+1]|| a[i+1] == k)
  25. {
  26.  
  27. k = a[i+1];
  28. a[i+1] = '0';
  29.  
  30.  
  31. }
  32. }
  33.  
  34. for(int i =0; i < n; i++)
  35. {
  36. if(a[i] == '0')
  37. {
  38. q++;
  39. }
  40.  
  41. }
  42. cout << endl << endl;
  43.  
  44. for(int i =0; i < n; i++)
  45. {
  46. cout << a[i];
  47.  
  48. }
  49.  
  50. cout << endl << endl;
  51. cout << q;
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement