Back
Bai1.cpp
Save
// Bai1.cpp #include
using namespace std; int a[] = {83,86,77,15,93,35,86,92,49,21,62,27,90,59,63}; int k = 34; int Find(int a[], int l, int r) { if (l == r) { if (a[l] > k) return a[l]; else return INT_MAX; } else { int m = (l + r) / 2; int f1 = Find(a, l, m); int f2 = Find(a, m + 1, r); if (f1 < f2) return f1; else return f2; } } int main() { cout << Find(a, 0, 14); return 0; }