Skip to content

Conversation

@MinyazevR
Copy link
Owner

No description provided.

Copy link

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

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

Вообще, не считая весьма досадной путаницы с позициями, годно и аккуратно. Но не работает

Comment on lines +81 to +83
free(element);

}

Choose a reason for hiding this comment

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

Suggested change
free(element);
}
free(element);
}

#pragma once
#include "../../List/List/List.h"

int readFile(const char* filename, List* list);

Choose a reason for hiding this comment

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

Надо бы комментарии ещё

#include <string.h>
#include <stdlib.h>

List* removeRepeatElement(List* list, Error* error)

Choose a reason for hiding this comment

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

"Repeating" лучше

List* newList = createList(error);
Position* position = first(list, error);
Position* newPosition = first(list, error);
while(!isLastElement(position))

Choose a reason for hiding this comment

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

Suggested change
while(!isLastElement(position))
while (!isLastElement(position))

Position* newPosition = first(list, error);
while(!isLastElement(position))
{
newPosition = position;

Choose a reason for hiding this comment

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

Не-а, это не "создать копию позиции position", это "давайте эту же область памяти, на которую указывает position, называть ещё newPosition". Поэтому когда Вы делаете newPosition = next(newPosition);, продвигается и position тоже. Ваш код к этому морально не готов и падает после первой итерации внешнего цикла. Надо было сделать функцию копирования позиции, и всё бы заработало. В отладчике же видно, что происходит :)

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