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