Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int position(double x, const vector<double>& v, int left, int right) {
- if (left > right) return -1;
- int mid = (left+right)/2;
- if (x < v[mid]) return position(x, v, left, mid-1);
- if (x > v[mid]) return position(x, v, mid+1, right);
- return mid;
- }
- // (c) Carlos Sansón (Best pro1 delegate ever for sure) @csansoon
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement