class BaseBSearch { static public int Go(int[] x, int n, int t) { int l = 0, u = n - 1, p = 0, m = 0; while (true) { if (l > u) { p = -1; break; } m = (l + u) /2; if (x[m] < t) { l = m + 1; } else if (x[m] == t) { p = m; break; } else if (x[m] > t) { u = m - 1; } } return p; } }