Skip to content

Comments

Контрольная работа(2)#9

Open
shannami wants to merge 6 commits intomainfrom
ControlTest2
Open

Контрольная работа(2)#9
shannami wants to merge 6 commits intomainfrom
ControlTest2

Conversation

@shannami
Copy link
Owner

@shannami shannami commented Dec 1, 2025

Шалахина Анна б43

@shannami shannami requested a review from WoWaster December 1, 2025 12:13
WoWaster
WoWaster previously approved these changes Dec 5, 2025
#include "task2.h"


int CompareBin(bool A[], bool B[], 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.

Функции по стайлгайду называются в camelCase, переменные тоже.

Также к функциям принято писать комментарии. Здесь он очень нужен, потому что трактовка возвращаемого значения нетривиальна.


int CompareBin(bool A[], bool B[], int n)
{
for (int i = 0; i < n; i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

А если у чисел разная длина? Какой тогда контракт?

Comment on lines +17 to +40
int main()
{
int n;
scanf("%d", &n);

bool A[n], B[n];

for (int i = 0; i < n; i++)
scanf("%d", (int*)&A[i]);

for (int i = 0; i < n; i++)
scanf("%d", (int*)&B[i]);

int r = CompareBin(A, B, n);

if (r > 0)
printf("A > B\n");
else if
(r < 0) printf("A < B\n");
else
printf("A = B\n");

return 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Зачем Вам в библиотеке интерактивный main? Почему тестов не хватает?

Ещё и с глупыми ошибками типа кривого форматирования и неициализированных переменных.

@@ -0,0 +1,4 @@
#pragma once
#include <stdbool.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Если здесь уже есть stdbool.h, то в .c файле он не нужен.

Copy link
Collaborator

Choose a reason for hiding this comment

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

6 баллов.

Node* curr = head;
while (curr) {
Node* next = curr->next;
curr->next = prev;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Здесь можно записать в нулевой указатель

Node* reverse(Node* head) {
Node* prev = NULL;
Node* curr = head;
while (curr) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Если я правильно всё посчитал, то после одного шага цикла над списком из трех элементов, ссылка на последний элемент потеряется и всё.

Copy link
Collaborator

Choose a reason for hiding this comment

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

4 балла за попытку.

@shannami shannami dismissed WoWaster’s stale review December 9, 2025 00:46

The merge-base changed after approval.

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