From 6ef0a8bfb3ecdcbdbee5504652273ff02f9ce921 Mon Sep 17 00:00:00 2001 From: AZEN-SGG Date: Wed, 21 May 2025 12:31:06 +0300 Subject: [PATCH] Task 7 is done --- 2025.05.23/04Ex/input/a.txt | 7 +++++ 2025.05.23/04Ex/input/e.txt | 0 2025.05.23/04Ex/input/f.txt | 5 ++++ 2025.05.23/04Ex/input/n.txt | 9 ++++++ 2025.05.23/04Ex/input/o.txt | 5 ++++ 2025.05.23/04Ex/input/s.txt | 6 ++++ 2025.05.23/04Ex/solve.c | 5 ++++ 2025.05.23/06Ex/solve.c | 12 ++++++-- 2025.05.23/07Ex/input/a.txt | 26 +++++++---------- 2025.05.23/07Ex/input/c.txt | 5 ++++ 2025.05.23/07Ex/input/m.txt | 31 +++++++++++++++++++++ 2025.05.23/07Ex/input/n.txt | 5 ++++ 2025.05.23/07Ex/input/s.txt | 11 ++++++++ 2025.05.23/07Ex/solve.c | 19 ++++++------- 2025.05.23/dist/Krivoruchenko_SK/solve_04.c | 5 ++++ 2025.05.23/dist/Krivoruchenko_SK/solve_06.c | 12 ++++++-- 2025.05.23/dist/Krivoruchenko_SK/solve_07.c | 19 ++++++------- 17 files changed, 138 insertions(+), 44 deletions(-) create mode 100644 2025.05.23/04Ex/input/a.txt create mode 100644 2025.05.23/04Ex/input/e.txt create mode 100644 2025.05.23/04Ex/input/f.txt create mode 100644 2025.05.23/04Ex/input/n.txt create mode 100644 2025.05.23/04Ex/input/o.txt create mode 100644 2025.05.23/04Ex/input/s.txt create mode 100644 2025.05.23/07Ex/input/c.txt create mode 100644 2025.05.23/07Ex/input/m.txt create mode 100644 2025.05.23/07Ex/input/n.txt create mode 100644 2025.05.23/07Ex/input/s.txt diff --git a/2025.05.23/04Ex/input/a.txt b/2025.05.23/04Ex/input/a.txt new file mode 100644 index 0000000..e1bae21 --- /dev/null +++ b/2025.05.23/04Ex/input/a.txt @@ -0,0 +1,7 @@ +1 +5 +4 +3 +2 +3 +1 diff --git a/2025.05.23/04Ex/input/e.txt b/2025.05.23/04Ex/input/e.txt new file mode 100644 index 0000000..e69de29 diff --git a/2025.05.23/04Ex/input/f.txt b/2025.05.23/04Ex/input/f.txt new file mode 100644 index 0000000..9fecd6b --- /dev/null +++ b/2025.05.23/04Ex/input/f.txt @@ -0,0 +1,5 @@ +5 +5 +5 +5 +5 diff --git a/2025.05.23/04Ex/input/n.txt b/2025.05.23/04Ex/input/n.txt new file mode 100644 index 0000000..2f15c52 --- /dev/null +++ b/2025.05.23/04Ex/input/n.txt @@ -0,0 +1,9 @@ +1 +5 +4 +4 +4 +4 +4 +6 +1 diff --git a/2025.05.23/04Ex/input/o.txt b/2025.05.23/04Ex/input/o.txt new file mode 100644 index 0000000..8a1218a --- /dev/null +++ b/2025.05.23/04Ex/input/o.txt @@ -0,0 +1,5 @@ +1 +2 +3 +4 +5 diff --git a/2025.05.23/04Ex/input/s.txt b/2025.05.23/04Ex/input/s.txt new file mode 100644 index 0000000..252e797 --- /dev/null +++ b/2025.05.23/04Ex/input/s.txt @@ -0,0 +1,6 @@ +1 +5 +5 +5 +5 +6 diff --git a/2025.05.23/04Ex/solve.c b/2025.05.23/04Ex/solve.c index d751de4..dc7b443 100644 --- a/2025.05.23/04Ex/solve.c +++ b/2025.05.23/04Ex/solve.c @@ -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; } diff --git a/2025.05.23/06Ex/solve.c b/2025.05.23/06Ex/solve.c index 5210f6e..ca831a6 100644 --- a/2025.05.23/06Ex/solve.c +++ b/2025.05.23/06Ex/solve.c @@ -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; } diff --git a/2025.05.23/07Ex/input/a.txt b/2025.05.23/07Ex/input/a.txt index 06e607e..85bad7c 100644 --- a/2025.05.23/07Ex/input/a.txt +++ b/2025.05.23/07Ex/input/a.txt @@ -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 diff --git a/2025.05.23/07Ex/input/c.txt b/2025.05.23/07Ex/input/c.txt new file mode 100644 index 0000000..627e109 --- /dev/null +++ b/2025.05.23/07Ex/input/c.txt @@ -0,0 +1,5 @@ +1 +1 +1 +1 +1 diff --git a/2025.05.23/07Ex/input/m.txt b/2025.05.23/07Ex/input/m.txt new file mode 100644 index 0000000..4ac2eee --- /dev/null +++ b/2025.05.23/07Ex/input/m.txt @@ -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 diff --git a/2025.05.23/07Ex/input/n.txt b/2025.05.23/07Ex/input/n.txt new file mode 100644 index 0000000..8a1218a --- /dev/null +++ b/2025.05.23/07Ex/input/n.txt @@ -0,0 +1,5 @@ +1 +2 +3 +4 +5 diff --git a/2025.05.23/07Ex/input/s.txt b/2025.05.23/07Ex/input/s.txt new file mode 100644 index 0000000..3255694 --- /dev/null +++ b/2025.05.23/07Ex/input/s.txt @@ -0,0 +1,11 @@ +1 +2 +3 +4 +4 +4 +4 +4 +5 +6 +7 diff --git a/2025.05.23/07Ex/solve.c b/2025.05.23/07Ex/solve.c index 70463eb..6ed5ffd 100644 --- a/2025.05.23/07Ex/solve.c +++ b/2025.05.23/07Ex/solve.c @@ -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; } diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_04.c b/2025.05.23/dist/Krivoruchenko_SK/solve_04.c index 90a0db6..99a8ade 100644 --- a/2025.05.23/dist/Krivoruchenko_SK/solve_04.c +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_04.c @@ -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; } diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_06.c b/2025.05.23/dist/Krivoruchenko_SK/solve_06.c index 2c334dc..9cf1acc 100644 --- a/2025.05.23/dist/Krivoruchenko_SK/solve_06.c +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_06.c @@ -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; } diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_07.c b/2025.05.23/dist/Krivoruchenko_SK/solve_07.c index 25ada02..36b702d 100644 --- a/2025.05.23/dist/Krivoruchenko_SK/solve_07.c +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_07.c @@ -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; }