#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 y): ");
// cal 関数を呼び出して計算
cal(x, y, &sum, &diff, &mul, &mod);
// 計算結果を表示
printf("Difference: %d\n", diff
); printf("Quotient (integer division): %d\n", mod
);
return 0;
}
// cal 関数の定義
void cal(int x, int y, int *sum, int *diff, int *mul, int *mod) {
// 和
*sum = x + y;
// 差 (差は絶対値を取る)
// 積
*mul = x * y;
// 商 (整数の除算)
if (y != 0) {
*mod = x / y; // 整数の商を求める
} else {
*mod = 0; // ゼロ除算を防ぐため
printf("Warning: Division by zero.\n"); }
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgl2b2lkIGNhbChpbnQgeCwgaW50IHksIGludCAqc3VtLCBpbnQgKmRpZmYsIGludCAqbXVsLCBpbnQgKm1vZCk7CgppbnQgbWFpbigpIHsKICAgIC8vIHgsIHksIHN1bSwgZGlmZiwgbXVsLCBtb2Qg44Gu5a6a576pCiAgICBpbnQgeCwgeSwgc3VtLCBkaWZmLCBtdWwsIG1vZDsKCiAgICAvLyB4IOOBqCB5IOOBq+WApOOCkuWFpeWKmwogICAgcHJpbnRmKCJFbnRlciB0d28gaW50ZWdlcnMgKHggeSk6ICIpOwogICAgc2NhbmYoIiVkICVkIiwgJngsICZ5KTsKCiAgICAvLyBjYWwg6Zai5pWw44KS5ZG844Gz5Ye644GX44Gm6KiI566XCiAgICBjYWwoeCwgeSwgJnN1bSwgJmRpZmYsICZtdWwsICZtb2QpOwoKICAgIC8vIOioiOeul+e1kOaenOOCkuihqOekugogICAgcHJpbnRmKCJTdW06ICVkXG4iLCBzdW0pOwogICAgcHJpbnRmKCJEaWZmZXJlbmNlOiAlZFxuIiwgZGlmZik7CiAgICBwcmludGYoIlByb2R1Y3Q6ICVkXG4iLCBtdWwpOwogICAgcHJpbnRmKCJRdW90aWVudCAoaW50ZWdlciBk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