Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Leson_1_p3.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include <iostream>
- using namespace std;
- int main()
- {
- bool isNotGameOver = true;
- cout << "Please choose the number from 1 to 100\n";
- int currentNumber = 50;
- char answer;
- while (isNotGameOver)
- {
- cout << "Is this number: " << currentNumber << "\nPlease enter y\\n\n";
- cin >> answer;
- if (answer == 'y')
- {
- isNotGameOver = false;
- }
- else if (answer == 'n')
- {
- cout << "Is it BIGGER than " << currentNumber << "?(y\\n)\n";
- cin >> answer;
- if (answer == 'y')
- {
- currentNumber = currentNumber + (currentNumber - (currentNumber / 2));
- }
- else if (answer == 'n')
- {
- currentNumber = currentNumber - (currentNumber - (currentNumber / 2));
- }
- isNotGameOver = true;
- }
- else
- {
- cout << "I don\'t understand you\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement