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