#include #include #include #include using namespace std; int main() { int min = 0, max = 100, temp; bool odp = false; char Tak_lub_nie; srand((unsigned)time(NULL)); cout << "Wymysl sobie jakas liczbe w przedziale od 1 do 100 i nacisnij dowolny klawisz." << endl; getch(); while(!odp) { temp = (rand() % (max - min)) + min + 1; if(temp >= max) temp =- 1; cout << "Czy twoja liczba to " << temp << " ?\n[t/n]: " << endl; Tak_lub_nie = getch(); if(Tak_lub_nie == 't' || Tak_lub_nie == 'T') { odp = true; break; } cout << "Czy twoja liczba jest wieksza od " << temp << " ?\n[t/n]: " << endl; Tak_lub_nie = getch(); if(Tak_lub_nie == 't' || Tak_lub_nie == 'T') min = temp; if(Tak_lub_nie == 'n' || Tak_lub_nie == 'N') max = temp; if((min - max) == 1) { odp = true; temp = min + 1; break; } } cout << "A wiec twoja liczba to " << temp << " ! Wygralem !!!" << endl; getch(); }