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;
  7. int sum, diff, mul, mod;
  8.  
  9. scanf("%d", &x);
  10. scanf("%d", &y);
  11.  
  12. cal(x, y, &sum, &diff, &mul, &mod);
  13.  
  14. printf("和=%d\n", sum);
  15. printf("差=%d\n", diff);
  16. printf("積=%d\n", mul);
  17. printf("商=%d\n", mod);
  18.  
  19. return 0;
  20. }
  21.  
  22. void cal(int x, int y, int *sum, int *diff, int *mul, int *mod){
  23.  
  24. *sum = x + y;
  25.  
  26. if(x > y){
  27. *diff = x - y;
  28. } else {
  29. *diff = y - x;
  30. }
  31.  
  32. *mul = x * y;
  33. *mod = x / y;
  34. }
  35.  
Success #stdin #stdout 0s 5320KB
stdin
2 3
stdout
和=5
差=1
積=6
商=0