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() {
  6. int x, y;
  7. int sum, diff, mul, mod;
  8.  
  9. printf("x と y を入力してください: ");
  10. scanf("%d %d", &x, &y);
  11. cal(x, y, &sum, &diff, &mul, &mod);
  12.  
  13. printf("x + y = %d\n", sum);
  14. printf("|x - y| = %d\n", diff);
  15. printf("x * y = %d\n", mul);
  16. printf("x / y = %d\n", mod);
  17.  
  18. return 0;
  19. }
  20. void cal(int x, int y, int *sum, int *diff, int *mul, int *mod) {
  21. *sum = x + y;
  22. *diff = (x > y) ? (x - y) : (y - x);
  23. *mul = x * y;
  24. *mod = x / y;
  25. }
Success #stdin #stdout 0s 5260KB
stdin
3
5
stdout
x と y を入力してください: x + y = 8
|x - y| = 2
x * y = 15
x / y = 0