fork download
  1. #include <stdio.h>
  2.  
  3. void swap(int *x, int *y){
  4. int tmp = *y;
  5. *y = *x;
  6. *x = tmp;
  7. }
  8.  
  9. int main() {
  10. int a = 3;
  11. int b = 1;
  12. int c = 2;
  13.  
  14. printf("a=%d, b=%d, c=%d\n", a,b,c);
  15.  
  16. if(a>b)
  17. swap(&a,&b);
  18.  
  19. if(b>c)
  20. swap(&b,&c);
  21.  
  22. if(a>b)
  23. swap(&a,&b);
  24. printf("a=%d, b=%d, c=%d\n", a,b,c);
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
a=3, b=1, c=2
a=1, b=2, c=3