Advertisement
Josif_tepe

Untitled

Nov 5th, 2021
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     cout << "Dobredojdovte vo igrata!" << endl;
  7.     cout << "Zamislete broj od 1 do 100.000 i zapisete go na list hartija" << endl;
  8.     int od_kade = 1;
  9.     int do_kade = 100000;
  10.    
  11.     while(od_kade <= do_kade) {
  12.         int sredina = (od_kade + do_kade) / 2;
  13.         cout << "Ako vasiot broj e ednakov na " << sredina << " vnesete 0, ako e pogolem vnesete 1, a ako e pomal vnesete -1" << endl;
  14.         int x;
  15.         cin >> x;
  16.        
  17.         if(x == 0) {
  18.             cout << "Vasiot zamislen broj e " << sredina << endl;
  19.         }
  20.         else if(x == 1) {
  21.             od_kade = sredina + 1;
  22.         }
  23.         else if(x == -1) {
  24.             do_kade = sredina - 1;
  25.         }
  26.     }
  27.     return 0;
  28. }
  29. // 73 420
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement