Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- // 971
- int main() {
- cout << "Zamislete broj od 1 do 1000, i ke go pogodime vo 11 prasanja" << endl;
- int L = 1, R = 1000;
- while(L <= R) {
- int middle = (L + R) / 2;
- cout << "Ako vasiot broj e ednakov na " << middle << " vnesete 0, ako e pomal vnesete -1, a ako e pogolem vnesete 1" << endl;
- int x;
- cin >> x;
- if(x == 0) {
- cout << "Vashiot broj e ednakov na " << middle << endl;
- break;
- }
- else if(x == 1) {
- L = middle + 1;
- }
- else {
- R = middle - 1;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement