fork download
  1. #include <stdio.h>
  2. void cal(int *x, int *y,int *sum, int *diff, int *mul, int *mod);
  3. void swap(int *x,int *y);
  4. void sort(int *x,int *y);
  5. int main(void) {
  6. int sum,mul,diff,mod;
  7. int x=3;
  8. int y=10;
  9. sort(&x,&y);
  10. cal(&x,&y,&sum,&diff,&mul,&mod);
  11. printf("x=%d\ny=%d\nsum=%d\ndiff=%d\nmul=%d\nmod=%d",x,y,sum,diff,mul,mod);
  12. return 0;
  13. }
  14. void sort(int *x,int *y){
  15. if(*x<*y){
  16. swap(x,y);
  17. }
  18. }
  19. void swap(int *x,int *y){
  20. int temp;
  21. temp=*x;
  22. *x=*y;
  23. *y=temp;
  24. }
  25. void cal(int *x, int *y, int *sum, int *diff, int *mul, int *mod){
  26. *sum=*x+*y;
  27. *diff=(*x>*y)?(*x-*y):(*y-*x);
  28. *mul=(*x)*(*y);
  29. *mod=(*x)/(*y);
  30. }
  31.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
x=10
y=3
sum=13
diff=7
mul=30
mod=3