Skip to content

Control Task#5

Open
stuffacc wants to merge 1 commit intomasterfrom
kr1
Open

Control Task#5
stuffacc wants to merge 1 commit intomasterfrom
kr1

Conversation

@stuffacc
Copy link
Owner

1.с
2.с

monkey.c

@stuffacc stuffacc requested a review from chernishev October 17, 2025 14:21
@stuffacc stuffacc self-assigned this Oct 17, 2025
Copy link

@p-senichenkov p-senichenkov left a comment

Choose a reason for hiding this comment

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

Палиндром: 8/10 (за неправильное использование строк)
Сумма цифр: 10/10
Обезьянья сортировка: 0/10 (задача не решена)

Кстати, у Вас файлы названы не в том порядке.

while (num > 0) {
int ost = num % 2;
num = num / 2;
string[index] = (char) (ost);

Choose a reason for hiding this comment

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

nit: обычно приведение форматируют так: (char)ost.

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

string[index] = (char) (ost);
index++;
}
string[index] = '\t';

Choose a reason for hiding this comment

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

Вы что ли рандомными символами терминируете строку? Конвенционально используется \0.

Comment on lines +14 to +15
int res = palindrom(string);
if (res == 1) {

Choose a reason for hiding this comment

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

Suggested change
int res = palindrom(string);
if (res == 1) {
if (palindrom(string)) {

}
}

void to2(char string[], int num) {

Choose a reason for hiding this comment

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

Тут есть интересная попытка обмануть пользователя. Имя string намекает на то, что на выходе будет строка символов, терминированная нулём. А по факту это массив целых чисел, терминированный табуляцией.

Если Ваша задача -- повалить программу, которая будет использовать Вашу библиотеку, то у Вас точно получится.

while (num > 0) {
int ost = num % 2;
num = num / 2;
string[index] = (char) (ost);

Choose a reason for hiding this comment

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

Просто на всякий случай: если скастить, например, int a = 7 к char, то он не превратится волшебным образом в '7'. Это будет '\a' (bell).


int palindrom(char string[]) {
int res = 1;
int size = sizeOfString(string);

Choose a reason for hiding this comment

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

Если бы string действительно была строкой, можно было бы воспользоваться strlen. Вот Вам ещё одна причина правильно использовать char.

Comment on lines +25 to +29





Choose a reason for hiding this comment

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

Если верить HWProj, Вы сдали задачу за три минуты до дедлайна. За это время можно было хотя бы минимально привести код в порядок.

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