fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. void delete_element(int x[], int& n, int k);
  7.  
  8. int main()
  9. {
  10. int a[] = { 1,2,3,4,5,6,7,8,9,10 };
  11. int n = 10;
  12. delete_element(a, n, 0);
  13. for (int i = 0; i < n; ++i)
  14. cout << a[i] << endl;
  15. return 0;
  16. }
  17.  
  18.  
  19. void delete_element(int x[], int& n, int k)
  20. {
  21. if (k < 0 || k > n - 1)
  22. {
  23. cout << "Wrong index of k " << k << endl;
  24. return;
  25. }
  26.  
  27. std::copy(x + k + 1, x + n, x + k);
  28. n--;
  29. }
  30.  
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
2
3
4
5
6
7
8
9
10