Skip to content

Фролов Кирилл Владимирович#3

Open
MrPlesk2 wants to merge 2 commits into
cppdevcourse:masterfrom
MrPlesk2:master
Open

Фролов Кирилл Владимирович#3
MrPlesk2 wants to merge 2 commits into
cppdevcourse:masterfrom
MrPlesk2:master

Conversation

@MrPlesk2

@MrPlesk2 MrPlesk2 commented Oct 5, 2025

Copy link
Copy Markdown

No description provided.

Comment thread main.cpp
Comment thread main.cpp Outdated
int main() {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<int> dist(1, 9);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А вот тут не совсем верно по 2 пунктам:

  1. Загадывать можно с 0, а число у вас генерируется в интервале [1, 9], а не [0, 9]
  2. Тип лучше выбрать беззнаковый

Comment thread main.cpp Outdated
std::mt19937 gen(rd());
std::uniform_int_distribution<int> dist(1, 9);

int random_num = dist(gen);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот объект лучше сделать константой

Comment thread main.cpp Outdated

int random_num = dist(gen);

std::cout << "Guess a number from 0 to 9: " << std::endl;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Согласно ТЗ, это приглашение должно печататься перед каждой попыткой пользователя угадать, а не 1 раз

Comment thread main.cpp Outdated
int random_num = dist(gen);

std::cout << "Guess a number from 0 to 9: " << std::endl;
int guessed_num;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше все-таки не оставлять неинициализированные переменные. В данном случае нек будет ни UB, ни ошибок, но с точки зрения поддержки и дальнейшего развития кода будет лучше всегда чем-то инициализировать

@czertyaka czertyaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Принято, PR вливать не нужно.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants