Skip to content

sorted list task#6

Open
stuffacc wants to merge 2 commits intomasterfrom
sorted_list
Open

sorted list task#6
stuffacc wants to merge 2 commits intomasterfrom
sorted_list

Conversation

@stuffacc
Copy link
Owner

No description provided.

@stuffacc stuffacc requested a review from chernishev November 16, 2025 13:23
while (inp != '0') {
int value;
switch (inp) {
case '1':

Choose a reason for hiding this comment

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

По стайлгайду switch формтируется не так. И ширина отступа -- 4 пробела.

6/sorted_list.c Outdated
Comment on lines 13 to 15
Node* node = malloc(sizeof(Node));
(*node).next = NULL;
(*node).value = value;

Choose a reason for hiding this comment

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

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

6/sorted_list.c Outdated
Node* buff = NULL;


while (current < value) {

Choose a reason for hiding this comment

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

Suggested change
while (current < value) {
while (head->value < value) {

6/sorted_list.c Outdated
Comment on lines 71 to 73
if ((*head).next == NULL) {

}

Choose a reason for hiding this comment

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

Это, наверное, лишнее.

6/sorted_list.c Outdated


void removeValue(List* list, int value) {
Node* head = (*list).head;

Choose a reason for hiding this comment

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

Не очень хорошо эту переменную называть head. Она head только в самом начале. А так это просто текущая просматриваемая вершина, например, current, или temp, или iter.

Comment on lines +77 to +83
if (buff != NULL) {
(*buff).next = (*iter).next;
}

else {
(*list).head = (*iter).next;
}

Choose a reason for hiding this comment

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

Форматирование должно быть не такое

return node;
}

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.

Кажется, эту функцию можно сделать короче. И removeValue тоже.

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