Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 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. if (a[i+1] != k)
  31. {
  32. k = 0;
  33. }
  34.  
  35. }
  36. }
  37.  
  38. for(int i =0; i < n; i++)
  39. {
  40. if(a[i] == '0')
  41. {
  42. q++;
  43. }
  44.  
  45. }
  46. cout << endl << endl;
  47.  
  48. for(int i =0; i < n; i++)
  49. {
  50. cout << a[i];
  51.  
  52. }
  53.  
  54. cout << endl << endl;
  55. cout << q;
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement