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

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

View file

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

View file

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

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) int t7_solve (node *head)
{ {
char *last = head->string; char *last = head->string;
int maximum = 0, count = 1; int maximum = 0, count = 0, consist = 0;
for (head = head->next; head; head = head->next) for (head = head->next; head; head = head->next)
{ {
if (strcmp(head->string, last)) if (strcmp(head->string, last) == 0) {
count++; if (maximum < count)
else { maximum = count - 1;
if (maximum < (count-1)) consist = 1;
maximum = count-1;
count = 0; count = 0;
} } else
count += consist;
last = head->string; last = head->string;
} }
if (maximum < count)
maximum = count;
return maximum; return maximum;
} }

View file

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

View file

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

View file

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