Skip to content

Контрольная 2. Разгуляева Ада#14

Open
ada1ra wants to merge 2 commits intomainfrom
kr_2
Open

Контрольная 2. Разгуляева Ада#14
ada1ra wants to merge 2 commits intomainfrom
kr_2

Conversation

@ada1ra
Copy link
Owner

@ada1ra ada1ra commented Dec 5, 2025

No description provided.

@ada1ra ada1ra requested a review from chernishev December 5, 2025 14:35
Copy link
Collaborator

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

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

Comment on lines +165 to +167
while (scanf("%d", &number) == 1 && number > 0) {
head = append(head, number);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Этот while имеет квадратичную сложность, хотя сам алгоритм линейный. А можно сделать это за O(n), если где-то сохранить указатель на последний элемент списка.

@@ -0,0 +1,40 @@
#ifndef PALINDROM_H
Copy link
Collaborator

Choose a reason for hiding this comment

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

По стайлгайду мы не используем include guards.

Node* createListFromArray(int arr[], int n);

// тест с несимметричным списком
void test1();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Тесты лучше выделить в отдельный файл.

@@ -0,0 +1,29 @@
#include <stdio.h>

int main()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Лучше не писать всё в main. Хотя бы потому, что у Вас не получится сделать юнит-тесты.

// собираем число с позиции start
for (int i = 0; i < N; i++) {
int idx = (start + i) % N;
current = (current << 1) | bits[idx]; // добавляем бит
Copy link
Collaborator

Choose a reason for hiding this comment

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

+2 балла за использование битовых операций (+5 я ставил только если циклический сдвиг тоже сделать на битовых операциях)

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