fork download
  1. #ifndef POINTER03_H_
  2. #define POINTER03_H_
  3.  
  4. #include <cstdio>
  5. #include <cstdlib>
  6. #include <cstring>
  7. #include <cassert>
  8.  
  9. void array_swap (int *arr[]);
  10.  
  11. int main ()
  12. {
  13. int n;
  14. scanf("%d", &n);
  15.  
  16. int **arr = (int **) malloc(sizeof(int*[n + 1]));
  17. int **brr = (int **) malloc(sizeof(int*[n + 1]));
  18. for (int i = 0; i < n; i++)
  19. {
  20. arr[i] = brr[i] = (int *) malloc(sizeof(int));
  21. scanf("%d", arr[i]);
  22. }
  23. arr[n] = brr[n] = NULL;
  24.  
  25. array_swap(arr);
  26.  
  27. for (int i = 0; i < n; i++)
  28. {
  29. if (arr[i] != brr[i])
  30. {
  31. printf("peach found someone cheating!\n");
  32. return 0;
  33. }
  34. printf("%d%c", *arr[i], " \n"[i == n - 1]);
  35. }
  36.  
  37. if (arr[n] != NULL)
  38. {
  39. printf("peach found someone cheating!\n");
  40. return 0;
  41. }
  42. }
  43. #endif // POINTER03_H_
  44.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty