#include <stdio.h>
// 関数の宣言
void cal(int x, int y, int *sum, int *diff, int *mul, int *mod);
int main() {
// 整数x, y, sum, diff, mul, modを定義
int x, y, sum, diff, mul, mod;
// x, y の値を入力
printf("Enter two integers (x and y): ");
// cal関数を呼び出して計算を実行
cal(x, y, &sum, &diff, &mul, &mod);
// 計算結果を表示
printf("Sum (x + y): %d\n", sum
); printf("Difference (|x - y|): %d\n", diff
); printf("Multiplication (x * y): %d\n", mul
); printf("Division (x / y, truncated): %d\n", mod
);
return 0;
}
// cal関数の定義
void cal(int x, int y, int *sum, int *diff, int *mul, int *mod) {
// 和を計算
*sum = x + y;
// 差を計算(絶対値)
*diff = (x > y) ? (x - y) : (y - x);
// 積を計算
*mul = x * y;
// 商を計算(小数点以下切り捨て)
*mod = x/y ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgovLyDplqLmlbDjga7lrqPoqIAKdm9pZCBjYWwoaW50IHgsIGludCB5LCBpbnQgKnN1bSwgaW50ICpkaWZmLCBpbnQgKm11bCwgaW50ICptb2QpOwoKaW50IG1haW4oKSB7CiAgICAvLyDmlbTmlbB4LCB5LCBzdW0sIGRpZmYsIG11bCwgbW9k44KS5a6a576pCiAgICBpbnQgeCwgeSwgc3VtLCBkaWZmLCBtdWwsIG1vZDsKCiAgICAvLyB4LCB5IOOBruWApOOCkuWFpeWKmwogICAgcHJpbnRmKCJFbnRlciB0d28gaW50ZWdlcnMgKHggYW5kIHkpOiAiKTsKICAgIHNjYW5mKCIlZCAlZCIsICZ4LCAmeSk7CgogICAgLy8gY2Fs6Zai5pWw44KS5ZG844Gz5Ye644GX44Gm6KiI566X44KS5a6f6KGMCiAgICBjYWwoeCwgeSwgJnN1bSwgJmRpZmYsICZtdWwsICZtb2QpOwoKICAgIC8vIOioiOeul+e1kOaenOOCkuihqOekugogICAgcHJpbnRmKCJTdW0gKHggKyB5KTogJWRcbiIsIHN1bSk7CiAgICBwcmludGYoIkRpZmZlcmVuY2UgKHx4IC0geXwpOiAlZFxuIiwgZGlmZik7CiAgICBwcmludGYoIk11bHRpcGxpY2F0aW9uICh4ICogeSk6ICVkXG4iLCBtdWwpOwogICAgcHJpbnRmKCJEaXZpc2lvbiAoeCAvIHksIHRydW5jYXRlZCk6ICVkXG4iLCBtb2QpOwoKICAgIHJldHVybiAwOwp9CgovLyBjYWzplqLmlbDjga7lrprnvqkKdm9pZCBjYWwoaW50IHgsIGludCB5LCBpbnQgKnN1bSwgaW50ICpkaWZmLCBpbnQgKm11bCwgaW50ICptb2QpIHsKICAgIC8vIOWSjOOCkuioiOeulwogICAgKnN1bSA9IHggKyB5OwoKICAgIC8vIOW3ruOCkuioiOeul++8iOe1tuWvvuWApO+8iQogICAgKmRpZmYgPSAoeCA+IHkpID8gKHggLSB5KSA6ICh5IC0geCk7CgogICAgLy8g56mN44KS6KiI566XCiAgICAqbXVsID0geCAqIHk7CgogICAgLy8g5ZWG44KS6KiI566X77yI5bCP5pWw54K55Lul5LiL5YiH44KK5o2o44Gm77yJCiAgICAqbW9kID0geC95IDsKfQ==