Skip to content

Контрольная работа 2#24

Open
EStarikov wants to merge 3 commits intomainfrom
controlwork2
Open

Контрольная работа 2#24
EStarikov wants to merge 3 commits intomainfrom
controlwork2

Conversation

@EStarikov
Copy link
Owner

No description provided.

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.

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

l->len = 0;
}

void push(List* l, int a)
Copy link
Collaborator

Choose a reason for hiding this comment

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

А что мешает сохранить tail в List и просто добавлять элементы после него?

int check(List* l)
{
Element* current = l->head.next;
while (current->next != NULL) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Опять же, наверное, удобно было бы хранить указатель на tail.

{
int a = 0;
for (int i = N - 1; i >= 0; i--) {
a += arr[i] * (int)pow(2, N - 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.

Не надо лишний раз работать с вещественными числами. Строго говоря, здесь можно получить неожиданные результаты (скорее всего, их не будет из-за оптимизаций компилятора. Попробуйте позапускать с -O0).

Есть масса других способов возвести двойку в степень и умножить на 0 или 1.

return a;
}

int biggest(int* arr, int N)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: В условии сказано, что на вход подаётся булевый массив, а не массив int.

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