#include <stdio.h>
int main() {
int arr[5] = {3, 1, 8, 5, 2};
int max, min, diff;
max = arr[0];
min = arr[0];
for (int i = 1; i < 5; i++) {
if (arr[i] > max) {
max = arr[i];
}
if (arr[i] < min) {
min = arr[i];
}
}
diff = max - min;
printf("最大値と最小値の差: %d\n", diff
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKICAgIGludCBhcnJbNV0gPSB7MywgMSwgOCwgNSwgMn07CiAgICBpbnQgbWF4LCBtaW4sIGRpZmY7CiAgICAKICAgIG1heCA9IGFyclswXTsKICAgIG1pbiA9IGFyclswXTsKICAgIAogICAgZm9yIChpbnQgaSA9IDE7IGkgPCA1OyBpKyspIHsKICAgICAgICBpZiAoYXJyW2ldID4gbWF4KSB7CiAgICAgICAgICAgIG1heCA9IGFycltpXTsKICAgICAgICB9CiAgICAgICAgaWYgKGFycltpXSA8IG1pbikgewogICAgICAgICAgICBtaW4gPSBhcnJbaV07CiAgICAgICAgfQogICAgfQogICAgCiAgICBkaWZmID0gbWF4IC0gbWluOwogICAgCiAgICBwcmludGYoIuacgOWkp+WApDogJWRcbiIsIG1heCk7CiAgICBwcmludGYoIuacgOWwj+WApDogJWRcbiIsIG1pbik7CiAgICBwcmludGYoIuacgOWkp+WApOOBqOacgOWwj+WApOOBruW3rjogJWRcbiIsIGRpZmYpOwogICAgCiAgICByZXR1cm4gMDsKfQo=