Facebook
From janix, 7 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 286
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6.  
  7. {
  8.     int high = 100;
  9.     int low = 0;
  10.     string str = "";
  11.     for (int i =0; i < 7; ++i)
  12.     {
  13.         cout << "Czy liczba jest > " << low + (high -low) /2 << endl;
  14.         cin >> str;
  15.         if (str == "t")
  16.         {
  17.             low += (high - low)/2;
  18.             if (high-low <=1)
  19.                 cout << "Twoja liczba, to: " << high << endl;
  20.             cout << "high == " << high << endl;
  21.             cout << "low == " << low << endl;
  22.         }
  23.         else if (str == "n")
  24.         {
  25.             high -= (high - low)/2;
  26.             if (high-low <=1)
  27.                 cout << "Twoja liczba, to: " << high << endl;
  28.             cout << "high == " << high << endl;
  29.             cout << "low == " << low << endl;
  30.         }
  31.     }
  32. }
  33.