Task 8 is done!

This commit is contained in:
AZEN-SGG 2025-05-19 17:40:38 +03:00
parent 29a24a797a
commit f8c00118de
15 changed files with 317 additions and 0 deletions

42
2025.05.23/08Ex/solve.c Normal file
View file

@ -0,0 +1,42 @@
#include "solve.h"
#include "node.h"
#include <string.h>
#include <stdlib.h>
node * t8_solve (node *head)
{
node *last = head;
node *curr, *next;
curr = head->next;
if (!curr)
return head;
while (strcmp(last->string, curr->string) >= 0) {
free(last->string);
free(last);
last = curr;
head = curr;
curr = curr->next;
if (!curr)
return head;
}
for (next = curr->next; next; next = curr->next)
{
if (strcmp(curr->string, next->string) >= 0) {
free(curr->string);
free(curr);
last->next = next;
} else
last = curr;
curr = next;
}
return head;
}