Skip to content

Conversation

@18thday
Copy link
Contributor

@18thday 18thday commented Jan 21, 2026

No description provided.


int64_t Addition(int a, int b) {
throw std::runtime_error{"Not implemented"};
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.

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

char new_char;

// Преобразуем символ по правилам
if (c >= '0' && c <= '9') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

есть готовые функции для данных проверок, например isdigit, лучше их использовать, так как понятное имя и стандартная функция лучше рукописного кода

next_new_char = delimiter;
} else {
next_new_char = '_';
}
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 (next_new_char == new_char) {
count++;
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 (next_new_char == new_char) {
count++;
next++;
} 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.

это короткая ветвь корректней сделать if (next_new_char != new_char) break и убрать else

}

// Начинаем вывод
printf("[");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

printf это не C++

if (!first) printf(",");
printf("DEST");
first = false;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

в данном случае это тоже дублирование, много однотипных действий с разными аргументами

}

constexpr double operator"" _m_to_cm(long double meters) {
return static_cast<double>(meters * 100.0L);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

использование magic value не принято в коде, удобнее сделать константы с понятными именами и уже их использовать в коде, безымянный namespace для их объединения как вариант использвоания

printf("1");
} else {
printf("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.

это должен быть тернарный оператор

// b*x + c = 0 → x = -c/b
double x = -static_cast<double>(c) / b;
std::cout << x << std::endl;
}
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 (discriminant < 0) {
// Отрицательный дискриминант - нет действительных корней
std::cout << "no solutions" << std::endl;
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, поскольку не придется листать оставшийся код, чтобы понять, что больше ничего не добавляется, а далее везде убраны else,


// Корень из среднего значения квадратов
return std::sqrt(mean_of_squares);
} No newline at end of file
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

double mean_of_squares = sum_of_squares / size;

// Корень из среднего значения квадратов
return std::sqrt(mean_of_squares);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

if (!reverseBytes) {
// Little-endian порядок (по умолчанию)
std::cout << "0x";
for (int i = 0; i < static_cast<int>(sizeof(temp)); i++) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

префиксный инкремент

unsigned char byte = (temp >> (i * 8)) & 0xFF;
std::cout << std::hex << std::setw(2) << std::setfill('0')
<< static_cast<unsigned int>(byte);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

дублирование тела функций

std::cout << std::hex << std::setw(2) << std::setfill('0')
<< static_cast<unsigned int>(byte);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

// Проверка на пустой диапазон
if (begin == end) {
count = 0;
return nullptr;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

current_start = current;
current_length = 1;
}
current++;
Copy link
Contributor Author

@18thday 18thday Jan 21, 2026

Choose a reason for hiding this comment

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

префиксный инкремент должен быть + если ++current выполняется всегда, может стоило переписать на for

if (begin == end) {
std::cout << "[]\n";
return;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

стоит объединить условия

last--;
if (last <= end) break;
}
}
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 else можно было написать компактнее


void SwapPtr(/* write arguments here */) {
throw std::runtime_error{"Not implemented"};
void SwapPtr(const int*& a, const int*& 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.

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

int** temp = a;
a = b;
b = temp;
} No newline at end of file
Copy link
Contributor Author

Choose a reason for hiding this comment

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

можно было реализовать одной функцией

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.

@winnermrco-boop основные моменты:

  • мало решено заданий
  • дублирование кода
  • нет использования стандартных функций првоерки диапазонов символов в CharChanger

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