Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- #include <conio.h>
- using namespace std;
- void check()
- {
- srand(static_cast<unsigned int>(time(0))); // Генератор случайных чисел
- int secretNumber = rand() % 100 + 1; // Диапозон от 1 до 100
- int guess;
- int round = 5;
- int lose = 5;
- int counter = 0;
- int life = 10;
- cout << "Welcome player" << endl << "Computer generates a range 0 to 100" << endl << "Wish you luck!" << endl;
- cout << "You're life is " << endl;
- do
- {
- cout << "Computer's number is: ";
- cin >> guess;
- counter++;
- lose--;
- life--;
- if (guess > secretNumber)
- {
- cout << "Too high!\n\n";
- if (counter >= 3)
- {
- cout << "range 0 to " << (lose + 1) * 25 << endl;
- secretNumber /= 2;
- cout << secretNumber << endl;
- if (lose <= 0)
- {
- cout << "Round is OVER!" << endl << "You're life is " << life << endl << endl << endl;
- }
- }
- }
- else if (guess < secretNumber)
- {
- cout << "Too low!\n\n";
- if (counter >= 3)
- {
- cout << "range 0 to " << (lose + 1) * 25 << endl;
- secretNumber /= 2;
- cout << secretNumber << endl;
- if (lose <= 0)
- {
- cout << "Round is OVER!" << endl << "You're life is " << life << endl << endl << endl;
- }
- }
- }
- else
- {
- life += 10;
- cout << "\nYou win + 10 bonuses lifes!" << endl << "You're life is " << life << endl;
- }
- } while (guess != secretNumber && counter != round);
- if (life > 0)
- {
- check();
- }
- else
- {
- cout << "Game is Over!" << endl;
- }
- }
- int main()
- {
- check();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement