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