Delete Leak, Task 10 is workgit add .!
This commit is contained in:
parent
651cc5c7d9
commit
bccb0a6617
44 changed files with 12 additions and 1124 deletions
56
2025.05.23/dist/Krivoruchenko_SK/solve_10.c
vendored
56
2025.05.23/dist/Krivoruchenko_SK/solve_10.c
vendored
|
@ -1,56 +0,0 @@
|
|||
#include "solve_10.h"
|
||||
#include "node.h"
|
||||
#include "io_node.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
node * t10_solve (node *head)
|
||||
{
|
||||
int down = 0;
|
||||
node *last, *curr, *next,
|
||||
*start;
|
||||
last=next=start=NULL;
|
||||
curr = head;
|
||||
|
||||
for (next=curr->next; next; next=curr->next)
|
||||
{
|
||||
if (strcmp(next->string, curr->string) <= 0) {
|
||||
if (!down)
|
||||
start = last;
|
||||
down++;
|
||||
} else {
|
||||
if (down) {
|
||||
if (start) {
|
||||
delete_nodes(start->next, down+1);
|
||||
start->next = next;
|
||||
last = start;
|
||||
} else {
|
||||
delete_nodes(head, down+1);
|
||||
head = next;
|
||||
last = NULL;
|
||||
}
|
||||
curr = NULL;
|
||||
}
|
||||
down = 0;
|
||||
}
|
||||
|
||||
last = curr;
|
||||
curr = next;
|
||||
}
|
||||
|
||||
if (down) {
|
||||
if (start) {
|
||||
delete_nodes(start->next, down+1);
|
||||
start->next = NULL;
|
||||
} else {
|
||||
delete_nodes(head, down+1);
|
||||
head = NULL;
|
||||
}
|
||||
curr = NULL;
|
||||
last = NULL;
|
||||
}
|
||||
|
||||
return head;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue