Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "StdAfx.h"
- #include <iostream>
- #include <conio.h>
- #include <random>
- #include <time.h>
- #include <cstring>
- using namespace std;
- int main(){
- setlocale(LC_ALL, "Rus");
- system("color 0A");
- int input;
- int number;
- int attempt = 0;
- int answer = 0;
- cout << "Я загадал число от 1 до 25, угадай его!" << endl;
- cout << "У тебя есть 10 попыток!" << endl;
- do{
- srand(time(NULL));
- number = rand() % 25 + 1;
- do{
- answer = 1;
- if (attempt != 10){
- cin >> input;
- if (input == number){
- cout << "Верно! Правильное число " << number << endl;
- cout << "Хочешь сыграть еще? (1 - да, 2 - выход)" << endl;
- do{
- cin >> answer;
- if (answer == 1){
- attempt = 6-1;
- cout << "Давай сыграем еще! У тебя есть "<< attempt << " попыток!" << endl;
- }
- else if (answer == 2){
- return 0;
- }
- else {
- cout << "Неправильное число! Введите 1 для продолжение или 2 для выхода!" << endl;
- }
- } while (answer != 1 || answer != 2);
- }
- else if (input < number){
- cout << "Побольше!" << endl;
- }
- else if (input > number){
- cout << "Поменьше!" << endl;
- }
- attempt++;
- }
- else {
- cout << "Твои попытки закончились! Ты проиграл, правильное число: " << number << endl;
- _getch();
- return 0;
- }
- } while (input == number);
- } while (answer = 1);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement