fork download
  1. #ifndef POINTER07_H_
  2. #define POINTER07_H_
  3. #include <cassert>
  4. #include <cstdio>
  5. #include <cstring>
  6. #include <cstdlib>
  7. #include <algorithm>
  8.  
  9. void sort_pointer(int *p[], int n);
  10.  
  11. int main() {
  12. int arr[5000], n, *pointer[5000];
  13. arr[0] = 1;
  14. arr[1] = 3;
  15. arr[2] = 4;
  16. arr[3] = 5;
  17. arr[4] = 2;
  18. pointer[0] = &arr[0];
  19. pointer[1] = &arr[2];
  20. pointer[2] = &arr[3];
  21. pointer[3] = &arr[4];
  22. pointer[4] = &arr[1];
  23. n = 5;
  24. sort_pointer(pointer, n);
  25. for(int i = 0; i < n; i++) {
  26. printf("%d", *pointer[i]);
  27. (i < n - 1)? printf(" "):printf("\n");
  28. }
  29. fclose(stdout);
  30. return 0;
  31. }
  32. #endif // POINTER07_H_
  33.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty