Advertisement
czlowiekzgon

Untitled

Nov 14th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. void remove(Gang **&ptr, int &size, int where) {
  2. Gang **sup_ptr = new Gang *[size - 1];
  3.  
  4. for (int i = 0; i < size; i++) {
  5. if (i == where) {
  6. delete ptr[i];
  7. }
  8. else if (i < where) {
  9.  
  10. sup_ptr[i] = ptr[i];
  11.  
  12. }
  13. else {
  14.  
  15. sup_ptr[i - 1] = ptr[i];
  16.  
  17. }
  18. }
  19. delete[] ptr;
  20. ptr = nullptr;
  21. ptr = sup_ptr;
  22. --size;
  23. }
  24.  
  25.  
  26.  
  27. void remove(Gang *&ptr, int &size, int where) {
  28. Gang *sup_ptr = new Gang[size - 1];
  29.  
  30. for (int i = 0; i < size; i++) {
  31.  
  32. if (i < where) {
  33.  
  34. sup_ptr[i] = ptr[i];
  35.  
  36. }
  37. else {
  38.  
  39. sup_ptr[i - 1] = ptr[i];
  40.  
  41. }
  42. }
  43. delete[] ptr;
  44.  
  45. ptr = sup_ptr;
  46. --size;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement