Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "Dobredojdovte vo igrata!" << endl;
- cout << "Zamislete broj od 1 do 100.000 i zapisete go na list hartija" << endl;
- int od_kade = 1;
- int do_kade = 100000;
- while(od_kade <= do_kade) {
- int sredina = (od_kade + do_kade) / 2;
- cout << "Ako vasiot broj e ednakov na " << sredina << " vnesete 0, ako e pogolem vnesete 1, a ako e pomal vnesete -1" << endl;
- int x;
- cin >> x;
- if(x == 0) {
- cout << "Vasiot zamislen broj e " << sredina << endl;
- }
- else if(x == 1) {
- od_kade = sredina + 1;
- }
- else if(x == -1) {
- do_kade = sredina - 1;
- }
- }
- return 0;
- }
- // 73 420
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement