Skip to content

Comments

ДЗ № 6.2 Считалочка, Шестаков Николай#12

Open
NicholayShestakov wants to merge 4 commits intomainfrom
schitalochka
Open

ДЗ № 6.2 Считалочка, Шестаков Николай#12
NicholayShestakov wants to merge 4 commits intomainfrom
schitalochka

Conversation

@NicholayShestakov
Copy link
Owner

Add

  • Cycled list specified for schitalochka library
  • Realization of schitalochka
  • Compilation instruction

Copy link
Collaborator

@WoWaster WoWaster 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 +40 to +43
void deleteList(List* list)
{
free(list);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Оптимистично. А вдруг инициализировали и решили удалить? Давайте всё-таки честно попробуем удалить элементы.

return value;
}

index = index < 0 ? (index % list->size + list->size) : (index % list->size);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Прикольно, но вообще, наверное, логично сделать индексы только положительными

// Deletes element with taken index. Changes index starting pointer on the next element after deleted.
// Takes pointer on the list and index of the element.
// Returns 0. If the element is the last returns element.
int deleteElement(List* list, int index);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Наверное, чуть красивее было бы сделать так:

Suggested change
int deleteElement(List* list, int index);
bool deleteElement(List* list, int index, int* out);

Если вернулось true, то удалили последний элемент и записали в out, в ином случае out не трогать.

И в целом, по большому счёту, 0 допустим только потому что Вы воинов нумеруете от 1, а не от 0.

int main()
{
int peopleCount, everyM;
printf("Enter people count and after how many people we kill human (Каждый k+1-ый будет убит) (separated by space): ");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Забавная смесь :)


int main()
{
int peopleCount, everyM;
Copy link
Collaborator

Choose a reason for hiding this comment

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

А инициализировать?..


List* people = createList(peopleCount);
int humanNumber = 0;
for (; !humanNumber; humanNumber = deleteElement(people, everyM)) { }
Copy link
Collaborator

Choose a reason for hiding this comment

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

while?

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