int BaseBSearch(int x[], int n, int t) { int l = 0; int u = n - 1; int 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; }