Task 7 is done

This commit is contained in:
AZEN-SGG 2025-05-21 12:31:06 +03:00
parent 6f21fa116f
commit 6ef0a8bfb3
17 changed files with 138 additions and 44 deletions

View file

@ -0,0 +1,7 @@
1
5
4
3
2
3
1

View file

View file

@ -0,0 +1,5 @@
5
5
5
5
5

View file

@ -0,0 +1,9 @@
1
5
4
4
4
4
4
6
1

View file

@ -0,0 +1,5 @@
1
2
3
4
5

View file

@ -0,0 +1,6 @@
1
5
5
5
5
6

View file

@ -42,6 +42,11 @@ int t4_solve (node *head)
last = head;
head = next;
}
if (strcmp(head->string, last->string) <= 0)
if (strict)
if (maximum < count)
maximum = count;
return maximum;
}

View file

@ -6,15 +6,21 @@
int t6_solve (node *head)
{
char *last = head->string;
int count = 1;
int count = 0, local = 0;
for (head = head->next; head; head = head->next)
{
if (strcmp(head->string, last))
count++;
if (strcmp(head->string, last) == 0)
local = 1;
else {
count += local;
local = 0;
}
last = head->string;
}
count += local;
return count;
}

View file

@ -1,16 +1,10 @@
a
b
d
e
c
c
c
d
d
d
d
a
a
a
1
1
2
3
4
5
6
6
6
6

View file

@ -0,0 +1,5 @@
1
1
1
1
1

View file

@ -0,0 +1,31 @@
1
2
3
4
5
6
6
1
7
7
1
2
6
6
6
6
3
2
4
5
5
5
5
5
1
2
3
4
5
6
7

View file

@ -0,0 +1,5 @@
1
2
3
4
5

View file

@ -0,0 +1,11 @@
1
2
3
4
4
4
4
4
5
6
7

View file

@ -6,23 +6,20 @@
int t7_solve (node *head)
{
char *last = head->string;
int maximum = 0, count = 1;
int maximum = 0, count = 0, consist = 0;
for (head = head->next; head; head = head->next)
{
if (strcmp(head->string, last))
count++;
else {
if (maximum < (count-1))
maximum = count-1;
count = 0;
}
if (strcmp(head->string, last) == 0) {
if (maximum < count)
maximum = count - 1;
consist = 1;
count = 0;
} else
count += consist;
last = head->string;
}
if (maximum < count)
maximum = count;
return maximum;
}

View file

@ -42,6 +42,11 @@ int t4_solve (node *head)
last = head;
head = next;
}
if (strcmp(head->string, last->string) <= 0)
if (strict)
if (maximum < count)
maximum = count;
return maximum;
}

View file

@ -6,15 +6,21 @@
int t6_solve (node *head)
{
char *last = head->string;
int count = 1;
int count = 0, local = 0;
for (head = head->next; head; head = head->next)
{
if (strcmp(head->string, last))
count++;
if (strcmp(head->string, last) == 0)
local = 1;
else {
count += local;
local = 0;
}
last = head->string;
}
count += local;
return count;
}

View file

@ -6,23 +6,20 @@
int t7_solve (node *head)
{
char *last = head->string;
int maximum = 0, count = 1;
int maximum = 0, count = 0, consist = 0;
for (head = head->next; head; head = head->next)
{
if (strcmp(head->string, last))
count++;
else {
if (maximum < (count-1))
maximum = count-1;
count = 0;
}
if (strcmp(head->string, last) == 0) {
if (maximum < count)
maximum = count - 1;
consist = 1;
count = 0;
} else
count += consist;
last = head->string;
}
if (maximum < count)
maximum = count;
return maximum;
}