Skip to content

Задание 01_week#1

Open
lefff123 wants to merge 22 commits intomainfrom
development
Open

Задание 01_week#1
lefff123 wants to merge 22 commits intomainfrom
development

Conversation

@lefff123
Copy link
Owner

не смог запустить тесты на своем компе. периодически коммитил для того, чтобы посмотреть, прошел ли тесты. по итогу к char_changer дописал функцию main, в которой перебирал тестовые значения. изначально выделял память под массив, сейчас сделал его на стеке. если стоит опасаться переполнения - могу переписать так, чтобы выделялась память на массив из кучи

@lefff123 lefff123 changed the title Development Задание 01_week Nov 28, 2025
@lefff123 lefff123 requested a review from 18thday December 2, 2025 03:40
@lefff123 lefff123 closed this Dec 9, 2025
@lefff123 lefff123 reopened this Dec 9, 2025

int64_t Addition(int a, int b) {
throw std::runtime_error{"Not implemented"};
int64_t c=static_cast<int64_t>(a)+static_cast<int64_t>(b);
Copy link
Collaborator

Choose a reason for hiding this comment

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

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


size_t CharChanger(char array[], size_t size, char delimiter = ' ')
{
char array_fin[size]={};
Copy link
Collaborator

Choose a reason for hiding this comment

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

пробелы


for (size_t i = 0; i < size-1; ++i)
{

Copy link
Collaborator

Choose a reason for hiding this comment

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

лишняя пустая строка

throw std::runtime_error{"Not implemented"};
size_t temp_ptr = 0; // переменная для хранения текущего положения данных в массиве

for (size_t i = 0; i < size-1; ++i)
Copy link
Collaborator

Choose a reason for hiding this comment

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

пробелы

++temp_ptr;
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

очень много лишнего кода и дублирование





Copy link
Collaborator

Choose a reason for hiding this comment

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

милльон пустых строк

throw std::runtime_error{"Not implemented"};
uint8_t value = static_cast<uint8_t>(flags);

if (value > 0b00111111) { // Если установлены биты вне диапазона 0-5
Copy link
Collaborator

Choose a reason for hiding this comment

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

magic value для этого есть ALL

return value* 2.54L;
};
constexpr long double operator""_ft_to_cm(long double value) {
return value *30.48L;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Очень много magic value и лишних литералов, все нужно выразить через константы которым дать осмысленные имена, например для 12, 2.54 и 30.48, достаточно для преобразований

throw std::runtime_error{"Not implemented"};
std::cout << "0b";

for (int i = 8*bytes - 1; i >= 0; --i)
Copy link
Collaborator

Choose a reason for hiding this comment

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

пробелы

std::cout << "no solutions";
}
} else {
std::cout << static_cast<double>(-c) / static_cast<double>(b);
Copy link
Collaborator

Choose a reason for hiding this comment

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

лишний каст, достаточно сделать один

if (a == 0) {
if (b == 0) {
if (c == 0) {
std::cout << "infinite solutions";
Copy link
Collaborator

Choose a reason for hiding this comment

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

лучше не делать такую вложенность, а объединить соответствующие условия для отдельных случаев и сделать короткие ветви с выводом нужного текста и выхода из функции

{
std::cout << std::setprecision(6) << (-b - std::sqrt(discr)) / (2.0 * a);

}
Copy link
Collaborator

@18thday 18thday Jan 12, 2026

Choose a reason for hiding this comment

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

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

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

return static_cast<double>(std::sqrt(sum/static_cast<double> (size)));
Copy link
Collaborator

@18thday 18thday Jan 12, 2026

Choose a reason for hiding this comment

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

лишние пробелы и недостающие пробелы

@@ -0,0 +1,16 @@
#include <stdexcept>

double ApplyOperations(double a, double b, double (*func[])(double x, double y), size_t size)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Задачи второй и третьей недели прокоментированы через ПР в основной репозиторий

Copy link
Collaborator

@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.

@lefff123 комментарии по решениям первой недели

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