Advertisement
STANAANDREY

T10/6/2020 3

Oct 7th, 2020
1,991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int check(int v[], int p, int q) {
  5.     if (p > q)
  6.         return 0;
  7.     int mid = (p + q) / 2;
  8.     if (v[mid] == mid)
  9.         return 1;
  10.     if (v[mid] > mid)
  11.         return check(v, p, mid - 1);
  12.     return check(v, mid + 1, q);
  13. }
  14.  
  15. int main() {
  16.     //driver code comes here
  17.     return 0;
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement