fork download
  1. #include <stdio.h>
  2.  
  3. void cal(int x, int y, int *sum, int *diff, int *mul, int *mod);
  4.  
  5. int main(void) {
  6. int x, y, sum, diff, mul, mod;
  7. scanf("%d", &x);
  8. scanf("%d", &y);
  9. printf("x:%d ", x);
  10. printf("y:%d ", y);
  11.  
  12. cal(x, y, &sum, &diff, &mul, &mod);
  13.  
  14. printf("add:%d diff:%d mul:%d mod:%d", sum, diff, mul, mod);
  15. return 0;
  16. }
  17.  
  18. void cal(int x, int y, int *sum, int *diff, int *mul, int *mod) {
  19. *sum = x + y;
  20. if(x > y){
  21. *diff = x - y;
  22. }
  23. else{
  24. *diff = (-1)*(x - y);
  25. }
  26. *mul = x*y;
  27. *mod = x/y;
  28.  
  29. }
  30.  
Success #stdin #stdout 0s 5284KB
stdin
8
5
stdout
x:8 y:5 add:13 diff:3 mul:40 mod:1