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