Untitled

 avatar
unknown
c_cpp
a year ago
596 B
3
Indexable
#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;
}
Editor is loading...
Leave a Comment