#include <stdio.h>
#include <stdlib.h>
#define CONST 1200
int is_first_closest(int values[], int n) {
int dist
= abs(values
[0] - CONST
); for (int i = 1; i < n; ++i) {
if (abs(values
[i
] - CONST
) < dist
) { return 0;
}
}
return 1;
}
int main() {
int values[3] = {900, 1050, 1400};
if (is_first_closest(values, 3)) {
printf("First value is closest.\n"); } else {
printf("First value is not closest.\n"); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCiNkZWZpbmUgQ09OU1QgMTIwMAoKaW50IGlzX2ZpcnN0X2Nsb3Nlc3QoaW50IHZhbHVlc1tdLCBpbnQgbikgewogICAgaW50IGRpc3QgPSBhYnModmFsdWVzWzBdIC0gQ09OU1QpOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPCBuOyArK2kpIHsKICAgICAgICBpZiAoYWJzKHZhbHVlc1tpXSAtIENPTlNUKSA8IGRpc3QpIHsKICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIDE7Cn0KCmludCBtYWluKCkgewogICAgaW50IHZhbHVlc1szXSA9IHs5MDAsIDEwNTAsIDE0MDB9OwogICAgaWYgKGlzX2ZpcnN0X2Nsb3Nlc3QodmFsdWVzLCAzKSkgewogICAgICAgIHByaW50ZigiRmlyc3QgdmFsdWUgaXMgY2xvc2VzdC5cbiIpOwogICAgfSBlbHNlIHsKICAgICAgICBwcmludGYoIkZpcnN0IHZhbHVlIGlzIG5vdCBjbG9zZXN0LlxuIik7CiAgICB9CiAgICByZXR1cm4gMDsKfQo=