Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- int x;
- cin >> x;
- int niza[n];
- for(int i = 0; i < n; i++) {
- cin >> niza[i];
- }
- sort(niza, niza + n);
- int L = 0, R = n - 1;
- while(L <= R) {
- int middle = (L + R) / 2;
- if(niza[middle] == x) {
- cout << "Ovoj broj postoi vo nizata" << endl;
- return 0;
- }
- if(niza[middle] < x) {
- L = middle + 1;
- }
- else {
- R = middle - 1;
- }
- }
- return 0;
- }
- /*
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement