fork(1) download
  1. #include <stdio.h>
  2.  
  3. void swap(int *a,int *b);
  4. void sort(int *a,int *b);
  5. int main(void) {
  6. // your code goes here
  7. int a,b;
  8. scanf("%d%d",&a,&b);
  9. sort(&a,&b);
  10. printf("(左から小さい順) a = %d b = %d",a,b);
  11. return 0;
  12. }
  13.  
  14. void swap(int *a,int *b){
  15.  
  16. if(*a > *b){
  17. int w;
  18. w = *a;
  19. *a = *b;
  20. *b = w;
  21. }
  22.  
  23. }
  24. void sort(int *a,int *b){
  25.  
  26. swap(&a,&b);
  27.  
  28. }
  29.  
Success #stdin #stdout 0s 5328KB
stdin
3
5
stdout
(左から小さい順) a = 3 b = 5