문제출처 : https://www.acmicpc.net/problem/3135
code
#include <stdio.h> #include <stdlib.h> int main() { int A, B, N, n[5] = { NULL }, i, min; scanf("%d %d", &A, &B); scanf("%d", &N); for (i = 0; i < N; i++) scanf("%d", &n[i]); min = abs(B - A); for (i = 0; i < N; i++) { if (abs(B - n[i]) < min) min = abs(B - n[i]); } if (min == abs(B - A)) printf("%d", min); else printf("%d", min + 1); return 0; }