Skip to content

Conversation

@18thday
Copy link
Contributor

@18thday 18thday commented Jan 13, 2026

No description provided.


int64_t Addition(int a, int b)
{
return static_cast<int64_t>(a) + static_cast<int64_t>(b);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Лишний каст, второй операнд не следует приводить явно, так как он бы преобразовался с помощью неявного каста. Принято использовать такую возможность и не писать явный каст самостоятельно второй раз

  • лишний отступ (8 пробелов сейчас)

}
}
else {
// ���������� ���������
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Комментарии не видны, вероятно проблемы с кодировкой, нужно для исходного файла задать UTF-8, тогда в репозитории буудет корректно отражаться

}
else {
// ���������� ���������
double discriminant = static_cast<double>(b) * static_cast<double>(b) - 4.0 * static_cast<double>(a) * static_cast<double>(c);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

лишние касты, достаточно у одного b, поскольку 4.0 литерал для числа с плавающей точкой, то a и b приведутся к double перед умножением на 4

void SolveQuadratic(int a, int b, int c) {
throw std::runtime_error{"Not implemented"};
if (a == 0)
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

оформление if должно быть в одном стиле

std::cout << "infinite solutions";
}
else {
std::cout << "no solutions";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

лучше избавиться от вложженности и для каждого особого случая сделать короткую ветвь с return будет лучше читаться

sumofSquares += values[i] * values[i];
}

double meanofSquares = sumofSquares / static_cast<double>(size);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

лишняя переменная и лишний каст, можно записать выражение сразу в строку нижу, так как переменная не используется больше, кастовать size к double не нужно он приведется неявно поскольку sumofSquares имеет тип double

double ApplyOperations(double a, double b /* other arguments */) {
throw std::runtime_error{"Not implemented"};
} No newline at end of file
double ApplyOperations(double a, double b, double (**funks)(double, double), size_t size) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

funcs тогда, от слова functions, имена лучше не русифицирвоать, + нагляднее был бы массив указателей на функцию чем указатель на указатель на функцию

/* return_type */ FindLastElement(/* ptr_type */ begin, /* ptr_type */ end, /* func_type */ predicate) {
throw std::runtime_error{"Not implemented"};
} No newline at end of file
int* FindLastElement(int* begin,int* end, bool (*predicate)(int)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

пробел после запятой пропал, + функция должна принимать и возвращать указатели на константу, так как функция не изменяет элементы и требований к возможности изменению по возвращаемому указателю нет

/* return_type */ FindAll(/* args */) {
throw std::runtime_error{"Not implemented"};
std::vector<size_t> FindAll(const std::vector<int>& container, bool (*predicate)(int)) {
std::vector<size_t> cont2;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pos - позиции было бы лучше для навания

Copy link
Contributor Author

@18thday 18thday left a comment

Choose a reason for hiding this comment

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

@manika88 по сделанным задачам основной момент:

  • лишние static_cast

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