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. cal(x,y,&sum,&diff,&mul,&mod);
  10. printf("sum=%d diff=%d mul=%d mod=%d",sum,diff,mul,mod);
  11. return 0;
  12. }
  13.  
  14. void cal(int x, int y, int *sum, int *diff, int *mul, int *mod){
  15. *sum=x+y;
  16. if(x>=y) *diff=x-y;
  17. else *diff=y-x;//x-yの絶対値
  18. *mul=x*y;
  19. *mod=x%y;
  20. }
Success #stdin #stdout 0s 5316KB
stdin
24 6
stdout
sum=30 diff=18 mul=144 mod=0