fork(5) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int comp(const void *a, const void *b){
  5. return *(int *)a - *(int *)b;
  6. }
  7.  
  8. int main(void){
  9. int A[5][2] = {{3, 4}, {1, 2}, {5, 6}, {9, 10}, {7, 8}};
  10. int B[5][2] = {{3, 4}, {1, 2}, {5, 6}, {9, 10}, {7, 8}};
  11. int *p = &A[0][0];
  12. int *q = &B[0][1];
  13. qsort(p, 5, sizeof(int) * 2, comp);
  14. qsort(q, 5, sizeof(int) * 2, comp);
  15. int i;
  16. for(i = 0 ; i < 5; i++){
  17. printf("(%d, %d) ", A[i][0], A[i][1]);
  18. }
  19. printf("\n");
  20. for(i = 0 ; i < 5; i++){
  21. printf("(%d, %d) ", B[i][0], B[i][1]);
  22. }
  23. printf("\n");
  24. system("pause");
  25. return 0;
  26. }
Success #stdin #stdout #stderr 0s 9432KB
stdin
Standard input is empty
stdout
(1, 2) (3, 4) (5, 6) (7, 8) (9, 10) 
(3, 2) (5, 4) (1, 6) (9, 8) (0, 10) 
stderr
sh: 1: pause: not found