Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- int niza[n];
- for(int i = 0; i < n; i++) {
- cin >> niza[i];
- }
- int x;
- cin >> x;
- int od_kade = 0;
- int do_kade = n - 1;
- while(od_kade <= do_kade) {
- int sredina = (od_kade + do_kade) / 2;
- if(niza[sredina] == x) {
- cout << "DA" << endl;
- return 0;
- }
- if(x < niza[sredina]) {
- do_kade = sredina - 1;
- }
- else {
- od_kade = sredina + 1;
- }
- }
- cout << "DOOM" << endl;
- return 0;
- }
- // 73 420
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement