Advertisement
KuriGohanAndKamehaX2

punkt JE

Nov 22nd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. int* w_arr(int* a) // ж)
  2. {
  3. int* w = new int[n];
  4. bool f = true;
  5.  
  6. for (int i = 0; i < n; i++)
  7. w[i] = 0;
  8.  
  9. for (int i = 1; i < n; i++)
  10. {
  11. if (a[i] != a[i - 1])
  12. if (f)
  13. {
  14. w[i-1] = a[i-1];
  15. if (i != n - 1 && a[i] == a[i + 1])
  16. f = false;
  17. }
  18. else
  19. f = !f;
  20. else
  21. f = false;
  22. }
  23. if (a[n - 1] != a[n - 2])
  24. w[n - 1] = a[n - 1];
  25.  
  26. return w;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement