-
Notifications
You must be signed in to change notification settings - Fork 33
Гасилова Мария #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Гасилова Мария #32
Conversation
for testing with empty week 04
|
|
||
| int64_t Addition(int a, int b) | ||
| { | ||
| return static_cast<int64_t>(a) + static_cast<int64_t>(b); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лишний каст, второй операнд не следует приводить явно, так как он бы преобразовался с помощью неявного каста. Принято использовать такую возможность и не писать явный каст самостоятельно второй раз
- лишний отступ (8 пробелов сейчас)
| } | ||
| } | ||
| else { | ||
| // ���������� ��������� |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) | ||
| { |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pos - позиции было бы лучше для навания
18thday
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manika88 по сделанным задачам основной момент:
- лишние static_cast
No description provided.