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. if(a>b){
  15. swap(&a,&b);
  16. }
  17. if(a>c){
  18. swap(&a,&c);
  19. }
  20. if(b>c){
  21. swap(&b,&c);
  22. }
  23.  
  24. printf("a=%d, b=%d, c=%d\n", a, b, c);
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
a=1,  b=2, c=3