贝壳研发笔试第一题卡在18%
贝壳研发笔试第一题为啥卡在18
不知道哪里错了,请教大佬是卡在哪个特殊用例上了?
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNext()) { int n = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); } int pos = 0; int min = Integer.MAX_VALUE; for (int i = 0; i < n - 1; i++) { int dif = Math.abs(a[i] - a[i + 1]); if (dif < min) { pos = i; min = dif; } } System.out.println(a[pos] + " " + a[pos + 1]); } } }