Untitled

mail@pastecode.io avatar
unknown
c_cpp
23 days ago
596 B
2
Indexable
Never
#include <vector>
#include <set>
#include <map>
#include <iostream>
using namespace std;


int main() {
    int L = 1, R = 1000;
    // 689
    while(L <= R) {
        int middle = (L + R) / 2;
        cout << "Vnesi -1 ako brojot e pomal od " << middle << ", ili 1 ako e pogolem, i vnesi 0 ako brojot e ednakov" << endl;
        int x;
        cin >> x;
        if(x == 0) {
            cout << "Brojot e " << middle << endl;
            break;
        }
        else if(x == -1) {
            R = middle - 1;
        }
        else {
            L = middle + 1;
        }
    }
    return 0;
}
Leave a Comment