Skip to content

kr 2#12

Open
stuffacc wants to merge 1 commit intomasterfrom
kr2
Open

kr 2#12
stuffacc wants to merge 1 commit intomasterfrom
kr2

Conversation

@stuffacc
Copy link
Owner

@stuffacc stuffacc commented Dec 5, 2025

No description provided.

@stuffacc stuffacc requested a review from chernishev December 5, 2025 14:30
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.

Палиндром: 23/20
Циклический сдвиг: 1/10



void initList(List* list) {
(*list).head = NULL;

Choose a reason for hiding this comment

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

Вы мне говорили, что научились пользоваться оператором ->. А здесь снова это. Вы что ли изучали C в ночь после контрольной?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Да, я помню про ->. Мне (*p). больше нравится, так понятнее что я делаю.

Если больше одного раза приходится разыменовывать, например, node->next->next->value или ((*(*(*node).next).next).value)
В этом случае через -> понятнее и проще

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

(*list).size = 0;
}

void addValue(List* list, int value) {

Choose a reason for hiding this comment

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

Элемент добавляется в начало списка, да? Надо бы как-то это указать. Естественно, самый предпочтительный вариант -- в имени функции: addValueToFront. Или хотя бы в комментарии.

Кстати, комментарии недо не забывать писать. Формально на контрольной можно снижать баллы за отстутсвие комментариев.

Comment on lines +33 to +35



Choose a reason for hiding this comment

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

Не забывайте о форматировании.

int size = (*list).size;
for (int i = 0; i < size; i++) {
int value = (*head).value;
addValue(&listReverse, value);

Choose a reason for hiding this comment

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

Вот тут оно и стреляет. Если не вчитываться в код addValue, кажется, что список просто копируется, и непонятно, где он разворачивается.

for (int i = 0; i < n; i++) {
int a;
scanf("%d", &a);
addValue(&list, a);

Choose a reason for hiding this comment

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

Кажется, Ваш алгоритм работает за O(n). За это я всем добавлял по 5 дополнительных баллов.


int n;
printf("Введите число: ");
scanf("%d", &n);

Choose a reason for hiding this comment

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

Нет, тут надо наоборот. Вводится массив, а вывести надо число.

Choose a reason for hiding this comment

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

Ещё нужны хоть какие-то тесты.

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