Загрузка данных


#include <iostream>
#include <cstdlib>
using namespace std;

int main() {
    int secret = rand() % 20 + 1;
    int number;
    int attempts = 0;

    cout << "Я загадал число от 1 до 20." << endl;

    do {
        cout << "Введите число: ";
        cin >> number;

        if (number < 1 || number > 20) {
            cout << "Ошибка! Введите число от 1 до 20." << endl;
        }
        else {
            attempts++;

            if (number > secret) {
                cout << "Слишком много!" << endl;
            }
            else if (number < secret) {
                cout << "Слишком мало!" << endl;
            }
            else {
                cout << "Вы угадали!" << endl;
                cout << "Попыток: " << attempts << endl;
            }
        }

    } while (number != secret);

    return 0;
}