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