fork download
  1. #include <stdio.h>
  2.  
  3. void swap(int *a, int *b) {
  4. int temp = *a;
  5. *a = *b;
  6. *b = temp;
  7. }
  8.  
  9. void sort(int *x, int *y) {
  10. if (*x < *y) {
  11. swap(&x, &y);
  12. }
  13. }
  14.  
  15. int main(void) {
  16. int x=2, y=8;
  17.  
  18. sort(&x, &y);
  19.  
  20. printf("降順に並べ替えた結果:x = %d, y = %d\n", x, y);
  21.  
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
降順に並べ替えた結果:x = 2, y = 8