2nd_Sem_Bogachev/2025.05.23/dist/Krivoruchenko_SK/solve_04.c
2025-05-19 20:33:04 +03:00

40 lines
627 B
C

#include "solve_04.h"
#include "node.h"
#include <string.h>
int t4_solve (node *head)
{
char *last = head->string;
int maximum = 0, count = 0, local = 1, strict = 1;
for (head = head->next; head; head = head->next)
{
int cmp = strcmp(head->string, last);
if (cmp > 0) {
count += local;
local = 1;
strict = 1;
} else if (cmp < 0) {
if (!strict)
count += local;
if (maximum < count)
maximum = count;
count = 0;
local = 1;
strict = 0;
} else {
local++;
}
last = head->string;
}
if (!strict)
count += local;
if (maximum < count)
maximum = count;
return maximum;
}