#include <stdio.h>
int main() {
int num1, num2, num3;
int min, max;
float result;
printf("*** Find (Minimum + Maximum) / Maximum ***\n"); printf("Enter 3 integers : "); scanf("%d %d %d", &num1
, &num2
, &num3
);
// หา Minimum
if (num1 <= num2 && num1 <= num3) {
min = num1;
} else if (num2 <= num1 && num2 <= num3) {
min = num2;
} else {
min = num3;
}
// หา Maximum
if (num1 >= num2 && num1 >= num3) {
max = num1;
} else if (num2 >= num1 && num2 >= num3) {
max = num2;
} else {
max = num3;
}
// คำนวณผลลัพธ์
result = (float)(min + max) / max;
// แสดงผลลัพธ์
printf("(Min + Max) / Max = (%d + %d) / %d = %.5f\n", min
, max
, max
, result
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKICAgIGludCBudW0xLCBudW0yLCBudW0zOwogICAgaW50IG1pbiwgbWF4OwogICAgZmxvYXQgcmVzdWx0OwoKICAgIHByaW50ZigiKioqIEZpbmQgKE1pbmltdW0gKyBNYXhpbXVtKSAvIE1heGltdW0gKioqXG4iKTsKICAgIHByaW50ZigiRW50ZXIgMyBpbnRlZ2VycyA6ICIpOwogICAgc2NhbmYoIiVkICVkICVkIiwgJm51bTEsICZudW0yLCAmbnVtMyk7CgogICAgLy8g4Lir4LiyIE1pbmltdW0KICAgIGlmIChudW0xIDw9IG51bTIgJiYgbnVtMSA8PSBudW0zKSB7CiAgICAgICAgbWluID0gbnVtMTsKICAgIH0gZWxzZSBpZiAobnVtMiA8PSBudW0xICYmIG51bTIgPD0gbnVtMykgewogICAgICAgIG1pbiA9IG51bTI7CiAgICB9IGVsc2UgewogICAgICAgIG1pbiA9IG51bTM7CiAgICB9CgogICAgLy8g4Lir4LiyIE1heGltdW0KICAgIGlmIChudW0xID49IG51bTIgJiYgbnVtMSA+PSBudW0zKSB7CiAgICAgICAgbWF4ID0gbnVtMTsKICAgIH0gZWxzZSBpZiAobnVtMiA+PSBudW0xICYmIG51bTIgPj0gbnVtMykgewogICAgICAgIG1heCA9IG51bTI7CiAgICB9IGVsc2UgewogICAgICAgIG1heCA9IG51bTM7CiAgICB9CgogICAgLy8g4LiE4Liz4LiZ4Lin4LiT4Lic4Lil4Lil4Lix4Lie4LiY4LmMCiAgICByZXN1bHQgPSAoZmxvYXQpKG1pbiArIG1heCkgLyBtYXg7CgogICAgLy8g4LmB4Liq4LiU4LiH4Lic4Lil4Lil4Lix4Lie4LiY4LmMCiAgICBwcmludGYoIihNaW4gKyBNYXgpIC8gTWF4ID0gKCVkICsgJWQpIC8gJWQgPSAlLjVmXG4iLCBtaW4sIG1heCwgbWF4LCByZXN1bHQpOwoKICAgIHJldHVybiAwOwp9