diff --git a/2025.05.23/02Ex/solve.c b/2025.05.23/02Ex/solve.c index acfc958..9318af6 100644 --- a/2025.05.23/02Ex/solve.c +++ b/2025.05.23/02Ex/solve.c @@ -6,7 +6,7 @@ int t2_solve (node *head) { char *last = head->string; - int count = 1; + int count = 0; for (head = head->next; head; head = head->next) { diff --git a/2025.05.23/03Ex/solve.c b/2025.05.23/03Ex/solve.c index 82af1c8..172021e 100644 --- a/2025.05.23/03Ex/solve.c +++ b/2025.05.23/03Ex/solve.c @@ -5,12 +5,15 @@ int t3_solve (node *head) { - char *last = head->string; - int count = 0, local = 1; + node *next = NULL; + int count = 0, local = 0; + + if (!head) + return 0; - for (head = head->next; head; head = head->next) + for (next = head->next; next; next = head->next) { - int cmp = strcmp(head->string, last); + int cmp = strcmp(next->string, head->string); if (cmp < 0) { if (local) { count += local; @@ -22,11 +25,9 @@ int t3_solve (node *head) } else local = 1; - last = head->string; + head = next; } - count += local; - return count; } diff --git a/2025.05.23/09Ex/solve.c b/2025.05.23/09Ex/solve.c index 3f63269..229c526 100644 --- a/2025.05.23/09Ex/solve.c +++ b/2025.05.23/09Ex/solve.c @@ -9,19 +9,19 @@ node * t9_solve (node *head) { int cmp_last, cmp_next; node *last, *curr, *next, - *deleted; - last=next=deleted=NULL; + *deleted = NULL; cmp_last=cmp_next=0; - curr = head; - if (!curr) + last = head; + if (!last) return NULL; + curr = last->next; + if (!curr) + return head; for (next = curr->next; next; next = curr->next) { if (deleted) cmp_last = strcmp(curr->string, deleted->string); - else if (!last) - cmp_last = 1; else cmp_last = strcmp(curr->string, last->string); cmp_next = strcmp(curr->string, next->string); // Как происходит обращение в память для структур? @@ -31,13 +31,9 @@ node * t9_solve (node *head) if (deleted) delete_node(deleted); deleted = curr; - if (last) { - last->next = next; - curr = last; - } else { - head = next; - curr = NULL; - } + + last->next = next; + curr = last; } else { if (deleted) @@ -48,23 +44,6 @@ node * t9_solve (node *head) curr = next; } - if (deleted) - cmp_last = strcmp(curr->string, deleted->string); - else if (!last) - cmp_last = 1; - else - cmp_last = strcmp(curr->string, last->string); - - if (cmp_last >= 0) - { - delete_node(curr); - if (last) - last->next = NULL; - else - head = NULL; - curr = NULL; - } - if (deleted) delete_node(deleted); diff --git a/2025.05.23/dist/Krivoruchenko_SK/main_01.c b/2025.05.23/dist/Krivoruchenko_SK/main_01.c new file mode 100644 index 0000000..8d9b1b0 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/main_01.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +#include "solve_01.h" +#include "node.h" +#include "io_node.h" +#include "status.h" + +/* ./a01.out p filename */ +int main (int argc, char *argv[]) +{ + node *head = NULL; + char *name; + double t; + int p, res, task = 1; + io_status ret; + + if ( + !((argc == 3) && + sscanf(argv[1], "%d", &p) == 1 && + argv[2]) + ) { + fprintf(stderr, "Usage: %s p filename\n", argv[0]); + return -1; + } + + name = argv[2]; + + ret = read_list(&head, name); + do { + switch (ret) { + case SUCCESS: + continue; + case ERR_OPEN: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_OPEN, name); + break; + case ERR_READ: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_READ, name); + break; + case ERR_MEM: + fprintf (stderr, "%s!\n", ERR_MSG_MEM); + break; + } + + delete_list(head); + return -2; + } while (0); + + print_list(head, p); + + t = clock(); + res = t1_solve(head); + t = (clock() - t) / CLOCKS_PER_SEC; + + delete_list(head); + + if (res < 0) { + fprintf (stderr, "%s : Task = %d Undefined error Elapsed = %.2f\n", argv[0], task, t); + return -3; + } else { + fprintf (stdout, "%s : Task = %d Result = %d Elapsed = %.2f\n", argv[0], task, res, t); + return 0; + } +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/main_02.c b/2025.05.23/dist/Krivoruchenko_SK/main_02.c new file mode 100644 index 0000000..3f2b94a --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/main_02.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +#include "solve_02.h" +#include "node.h" +#include "io_node.h" +#include "status.h" + +/* ./a02.out p filename */ +int main (int argc, char *argv[]) +{ + node *head = NULL; + char *name; + double t; + int p, res, task = 2; + io_status ret; + + if ( + !((argc == 3) && + sscanf(argv[1], "%d", &p) == 1 && + argv[2]) + ) { + fprintf(stderr, "Usage: %s p filename\n", argv[0]); + return -1; + } + + name = argv[2]; + + ret = read_list(&head, name); + do { + switch (ret) { + case SUCCESS: + continue; + case ERR_OPEN: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_OPEN, name); + break; + case ERR_READ: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_READ, name); + break; + case ERR_MEM: + fprintf (stderr, "%s!\n", ERR_MSG_MEM); + break; + } + + delete_list(head); + return -2; + } while (0); + + print_list(head, p); + + t = clock(); + res = t2_solve(head); + t = (clock() - t) / CLOCKS_PER_SEC; + + delete_list(head); + + if (res < 0) { + fprintf (stderr, "%s : Task = %d Undefined error Elapsed = %.2f\n", argv[0], task, t); + return -3; + } else { + fprintf (stdout, "%s : Task = %d Result = %d Elapsed = %.2f\n", argv[0], task, res, t); + return 0; + } +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/main_03.c b/2025.05.23/dist/Krivoruchenko_SK/main_03.c new file mode 100644 index 0000000..5a489e0 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/main_03.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +#include "solve_03.h" +#include "node.h" +#include "io_node.h" +#include "status.h" + +/* ./a03.out p filename */ +int main (int argc, char *argv[]) +{ + node *head = NULL; + char *name; + double t; + int p, res, task = 3; + io_status ret; + + if ( + !((argc == 3) && + sscanf(argv[1], "%d", &p) == 1 && + argv[2]) + ) { + fprintf(stderr, "Usage: %s p filename\n", argv[0]); + return -1; + } + + name = argv[2]; + + ret = read_list(&head, name); + do { + switch (ret) { + case SUCCESS: + continue; + case ERR_OPEN: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_OPEN, name); + break; + case ERR_READ: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_READ, name); + break; + case ERR_MEM: + fprintf (stderr, "%s!\n", ERR_MSG_MEM); + break; + } + + delete_list(head); + return -2; + } while (0); + + print_list(head, p); + + t = clock(); + res = t3_solve(head); + t = (clock() - t) / CLOCKS_PER_SEC; + + delete_list(head); + + if (res < 0) { + fprintf (stderr, "%s : Task = %d Undefined error Elapsed = %.2f\n", argv[0], task, t); + return -3; + } else { + fprintf (stdout, "%s : Task = %d Result = %d Elapsed = %.2f\n", argv[0], task, res, t); + return 0; + } +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/main_04.c b/2025.05.23/dist/Krivoruchenko_SK/main_04.c new file mode 100644 index 0000000..2ad507c --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/main_04.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +#include "solve_04.h" +#include "node.h" +#include "io_node.h" +#include "status.h" + +/* ./a04.out p filename */ +int main (int argc, char *argv[]) +{ + node *head = NULL; + char *name; + double t; + int p, res, task = 4; + io_status ret; + + if ( + !((argc == 3) && + sscanf(argv[1], "%d", &p) == 1 && + argv[2]) + ) { + fprintf(stderr, "Usage: %s p filename\n", argv[0]); + return -1; + } + + name = argv[2]; + + ret = read_list(&head, name); + do { + switch (ret) { + case SUCCESS: + continue; + case ERR_OPEN: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_OPEN, name); + break; + case ERR_READ: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_READ, name); + break; + case ERR_MEM: + fprintf (stderr, "%s!\n", ERR_MSG_MEM); + break; + } + + delete_list(head); + return -2; + } while (0); + + print_list(head, p); + + t = clock(); + res = t4_solve(head); + t = (clock() - t) / CLOCKS_PER_SEC; + + delete_list(head); + + if (res < 0) { + fprintf (stderr, "%s : Task = %d Undefined error Elapsed = %.2f\n", argv[0], task, t); + return -3; + } else { + fprintf (stdout, "%s : Task = %d Result = %d Elapsed = %.2f\n", argv[0], task, res, t); + return 0; + } +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/main_05.c b/2025.05.23/dist/Krivoruchenko_SK/main_05.c new file mode 100644 index 0000000..9153333 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/main_05.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +#include "solve_05.h" +#include "node.h" +#include "io_node.h" +#include "status.h" + +/* ./a05.out p filename */ +int main (int argc, char *argv[]) +{ + node *head = NULL; + char *name; + double t; + int p, res, task = 5; + io_status ret; + + if ( + !((argc == 3) && + sscanf(argv[1], "%d", &p) == 1 && + argv[2]) + ) { + fprintf(stderr, "Usage: %s p filename\n", argv[0]); + return -1; + } + + name = argv[2]; + + ret = read_list(&head, name); + do { + switch (ret) { + case SUCCESS: + continue; + case ERR_OPEN: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_OPEN, name); + break; + case ERR_READ: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_READ, name); + break; + case ERR_MEM: + fprintf (stderr, "%s!\n", ERR_MSG_MEM); + break; + } + + delete_list(head); + return -2; + } while (0); + + print_list(head, p); + + t = clock(); + res = t5_solve(head); + t = (clock() - t) / CLOCKS_PER_SEC; + + delete_list(head); + + if (res < 0) { + fprintf (stderr, "%s : Task = %d Undefined error Elapsed = %.2f\n", argv[0], task, t); + return -3; + } else { + fprintf (stdout, "%s : Task = %d Result = %d Elapsed = %.2f\n", argv[0], task, res, t); + return 0; + } +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/main_06.c b/2025.05.23/dist/Krivoruchenko_SK/main_06.c new file mode 100644 index 0000000..246af44 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/main_06.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +#include "solve_06.h" +#include "node.h" +#include "io_node.h" +#include "status.h" + +/* ./a06.out p filename */ +int main (int argc, char *argv[]) +{ + node *head = NULL; + char *name; + double t; + int p, res, task = 6; + io_status ret; + + if ( + !((argc == 3) && + sscanf(argv[1], "%d", &p) == 1 && + argv[2]) + ) { + fprintf(stderr, "Usage: %s p filename\n", argv[0]); + return -1; + } + + name = argv[2]; + + ret = read_list(&head, name); + do { + switch (ret) { + case SUCCESS: + continue; + case ERR_OPEN: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_OPEN, name); + break; + case ERR_READ: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_READ, name); + break; + case ERR_MEM: + fprintf (stderr, "%s!\n", ERR_MSG_MEM); + break; + } + + delete_list(head); + return -2; + } while (0); + + print_list(head, p); + + t = clock(); + res = t6_solve(head); + t = (clock() - t) / CLOCKS_PER_SEC; + + delete_list(head); + + if (res < 0) { + fprintf (stderr, "%s : Task = %d Undefined error Elapsed = %.2f\n", argv[0], task, t); + return -3; + } else { + fprintf (stdout, "%s : Task = %d Result = %d Elapsed = %.2f\n", argv[0], task, res, t); + return 0; + } +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/main_07.c b/2025.05.23/dist/Krivoruchenko_SK/main_07.c new file mode 100644 index 0000000..31d8345 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/main_07.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +#include "solve_07.h" +#include "node.h" +#include "io_node.h" +#include "status.h" + +/* ./a07.out p filename */ +int main (int argc, char *argv[]) +{ + node *head = NULL; + char *name; + double t; + int p, res, task = 7; + io_status ret; + + if ( + !((argc == 3) && + sscanf(argv[1], "%d", &p) == 1 && + argv[2]) + ) { + fprintf(stderr, "Usage: %s p filename\n", argv[0]); + return -1; + } + + name = argv[2]; + + ret = read_list(&head, name); + do { + switch (ret) { + case SUCCESS: + continue; + case ERR_OPEN: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_OPEN, name); + break; + case ERR_READ: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_READ, name); + break; + case ERR_MEM: + fprintf (stderr, "%s!\n", ERR_MSG_MEM); + break; + } + + delete_list(head); + return -2; + } while (0); + + print_list(head, p); + + t = clock(); + res = t7_solve(head); + t = (clock() - t) / CLOCKS_PER_SEC; + + delete_list(head); + + if (res < 0) { + fprintf (stderr, "%s : Task = %d Undefined error Elapsed = %.2f\n", argv[0], task, t); + return -3; + } else { + fprintf (stdout, "%s : Task = %d Result = %d Elapsed = %.2f\n", argv[0], task, res, t); + return 0; + } +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/main_08.c b/2025.05.23/dist/Krivoruchenko_SK/main_08.c new file mode 100644 index 0000000..15bc016 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/main_08.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +#include "solve_08.h" +#include "node.h" +#include "io_node.h" +#include "status.h" + +/* ./a08.out p filename */ +int main (int argc, char *argv[]) +{ + node *head = NULL; + char *name; + double t; + int p, len, task = 8; + io_status ret; + + if ( + !((argc == 3) && + sscanf(argv[1], "%d", &p) == 1 && + argv[2]) + ) { + fprintf(stderr, "Usage: %s p filename\n", argv[0]); + return -1; + } + + name = argv[2]; + + ret = read_list(&head, name); + do { + switch (ret) { + case SUCCESS: + continue; + case ERR_OPEN: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_OPEN, name); + break; + case ERR_READ: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_READ, name); + break; + case ERR_MEM: + fprintf (stderr, "%s!\n", ERR_MSG_MEM); + break; + } + + delete_list(head); + return -2; + } while (0); + + fprintf (stdout, "Source list:\n"); + print_list(head, p); + + t = clock(); + head = t8_solve(head); + t = (clock() - t) / CLOCKS_PER_SEC; + + fprintf (stdout, "\nFinal list:\n"); + print_list(head, p); + len = get_length(head); + + delete_list(head); + + fprintf (stdout, "%s : Task = %d Length = %d Elapsed = %.2f\n", argv[0], task, len, t); + return 0; +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/main_09.c b/2025.05.23/dist/Krivoruchenko_SK/main_09.c new file mode 100644 index 0000000..bcb92d5 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/main_09.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +#include "solve_09.h" +#include "node.h" +#include "io_node.h" +#include "status.h" + +/* ./a09.out p filename */ +int main (int argc, char *argv[]) +{ + node *head = NULL; + char *name; + double t; + int p, len, task = 9; + io_status ret; + + if ( + !((argc == 3) && + sscanf(argv[1], "%d", &p) == 1 && + argv[2]) + ) { + fprintf(stderr, "Usage: %s p filename\n", argv[0]); + return -1; + } + + name = argv[2]; + + ret = read_list(&head, name); + do { + switch (ret) { + case SUCCESS: + continue; + case ERR_OPEN: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_OPEN, name); + break; + case ERR_READ: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_READ, name); + break; + case ERR_MEM: + fprintf (stderr, "%s!\n", ERR_MSG_MEM); + break; + } + + delete_list(head); + return -2; + } while (0); + + fprintf (stdout, "Source list:\n"); + print_list(head, p); + + t = clock(); + head = t9_solve(head); + t = (clock() - t) / CLOCKS_PER_SEC; + + fprintf (stdout, "\nFinal list:\n"); + print_list(head, p); + len = get_length(head); + + delete_list(head); + + fprintf (stdout, "%s : Task = %d Length = %d Elapsed = %.2f\n", argv[0], task, len, t); + return 0; +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/main_10.c b/2025.05.23/dist/Krivoruchenko_SK/main_10.c new file mode 100644 index 0000000..803e50a --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/main_10.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +#include "solve_10.h" +#include "node.h" +#include "io_node.h" +#include "status.h" + +/* ./a10.out p filename */ +int main (int argc, char *argv[]) +{ + node *head = NULL; + char *name; + double t; + int p, len, task = 10; + io_status ret; + + if ( + !((argc == 3) && + sscanf(argv[1], "%d", &p) == 1 && + argv[2]) + ) { + fprintf(stderr, "Usage: %s p filename\n", argv[0]); + return -1; + } + + name = argv[2]; + + ret = read_list(&head, name); + do { + switch (ret) { + case SUCCESS: + continue; + case ERR_OPEN: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_OPEN, name); + break; + case ERR_READ: + fprintf (stderr, "%s '%s'!\n", ERR_MSG_READ, name); + break; + case ERR_MEM: + fprintf (stderr, "%s!\n", ERR_MSG_MEM); + break; + } + + delete_list(head); + return -2; + } while (0); + + fprintf (stdout, "Source list:\n"); + print_list(head, p); + + t = clock(); + head = t10_solve(head); + t = (clock() - t) / CLOCKS_PER_SEC; + + fprintf (stdout, "\nFinal list:\n"); + print_list(head, p); + len = get_length(head); + + delete_list(head); + + fprintf (stdout, "%s : Task = %d Length = %d Elapsed = %.2f\n", argv[0], task, len, t); + return 0; +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_01.c b/2025.05.23/dist/Krivoruchenko_SK/solve_01.c new file mode 100644 index 0000000..1071e91 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_01.c @@ -0,0 +1,23 @@ +#include "solve_01.h" +#include "node.h" + +#include + +int t1_solve (node *head) +{ + char *maximum = head->string; + int count = 1; + + for (head = head->next; head; head = head->next) + { + int cmp = strcmp(head->string, maximum); + if (cmp > 0) { + maximum = head->string; + count = 1; + } else if (!cmp) + count++; + } + + return count; +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_01.h b/2025.05.23/dist/Krivoruchenko_SK/solve_01.h new file mode 100644 index 0000000..69742a9 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_01.h @@ -0,0 +1,8 @@ +#ifndef SOLVE_H +#define SOLVE_H + +#include "node.h" + +int t1_solve (node *head); + +#endif diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_02.c b/2025.05.23/dist/Krivoruchenko_SK/solve_02.c new file mode 100644 index 0000000..665d3ab --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_02.c @@ -0,0 +1,20 @@ +#include "solve_02.h" +#include "node.h" + +#include + +int t2_solve (node *head) +{ + char *last = head->string; + int count = 0; + + for (head = head->next; head; head = head->next) + { + if (strcmp(head->string, last) > 0) + count++; + last = head->string; + } + + return count; +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_02.h b/2025.05.23/dist/Krivoruchenko_SK/solve_02.h new file mode 100644 index 0000000..8cd007e --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_02.h @@ -0,0 +1,8 @@ +#ifndef SOLVE_H +#define SOLVE_H + +#include "node.h" + +int t2_solve (node *head); + +#endif diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_03.c b/2025.05.23/dist/Krivoruchenko_SK/solve_03.c new file mode 100644 index 0000000..6542931 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_03.c @@ -0,0 +1,33 @@ +#include "solve_03.h" +#include "node.h" + +#include + +int t3_solve (node *head) +{ + node *next = NULL; + int count = 0, local = 0; + + if (!head) + return 0; + + for (next = head->next; next; next = head->next) + { + int cmp = strcmp(next->string, head->string); + if (cmp < 0) { + if (local) { + count += local; + local = 0; + } + } else if (cmp == 0) { + if (local) + local++; + } else + local = 1; + + head = next; + } + + return count; +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_03.h b/2025.05.23/dist/Krivoruchenko_SK/solve_03.h new file mode 100644 index 0000000..cbde131 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_03.h @@ -0,0 +1,8 @@ +#ifndef SOLVE_H +#define SOLVE_H + +#include "node.h" + +int t3_solve (node *head); + +#endif diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_04.c b/2025.05.23/dist/Krivoruchenko_SK/solve_04.c new file mode 100644 index 0000000..5e65862 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_04.c @@ -0,0 +1,40 @@ +#include "solve_04.h" +#include "node.h" + +#include + +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; +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_04.h b/2025.05.23/dist/Krivoruchenko_SK/solve_04.h new file mode 100644 index 0000000..6cb74f8 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_04.h @@ -0,0 +1,8 @@ +#ifndef SOLVE_H +#define SOLVE_H + +#include "node.h" + +int t4_solve (node *head); + +#endif diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_05.c b/2025.05.23/dist/Krivoruchenko_SK/solve_05.c new file mode 100644 index 0000000..14c38e4 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_05.c @@ -0,0 +1,27 @@ +#include "solve_05.h" +#include "node.h" + +#include + +int t5_solve (node *head) +{ + char *last = head->string; + int maximum = 1, count = 1; + + for (head = head->next; head; head = head->next) + { + if (strcmp(head->string, last) > 0) + count++; + else { + if (maximum < count) + maximum = count; + + count = 1; + } + + last = head->string; + } + + return maximum; +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_05.h b/2025.05.23/dist/Krivoruchenko_SK/solve_05.h new file mode 100644 index 0000000..126ce12 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_05.h @@ -0,0 +1,8 @@ +#ifndef SOLVE_H +#define SOLVE_H + +#include "node.h" + +int t5_solve (node *head); + +#endif diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_06.c b/2025.05.23/dist/Krivoruchenko_SK/solve_06.c new file mode 100644 index 0000000..2c334dc --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_06.c @@ -0,0 +1,20 @@ +#include "solve_06.h" +#include "node.h" + +#include + +int t6_solve (node *head) +{ + char *last = head->string; + int count = 1; + + for (head = head->next; head; head = head->next) + { + if (strcmp(head->string, last)) + count++; + last = head->string; + } + + return count; +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_06.h b/2025.05.23/dist/Krivoruchenko_SK/solve_06.h new file mode 100644 index 0000000..dbf48a3 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_06.h @@ -0,0 +1,8 @@ +#ifndef SOLVE_H +#define SOLVE_H + +#include "node.h" + +int t6_solve (node *head); + +#endif diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_07.c b/2025.05.23/dist/Krivoruchenko_SK/solve_07.c new file mode 100644 index 0000000..25ada02 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_07.c @@ -0,0 +1,28 @@ +#include "solve_07.h" +#include "node.h" + +#include + +int t7_solve (node *head) +{ + char *last = head->string; + int maximum = 0, count = 1; + + for (head = head->next; head; head = head->next) + { + if (strcmp(head->string, last)) + count++; + else { + if (maximum < (count-1)) + maximum = count-1; + count = 0; + } + last = head->string; + } + + if (maximum < count) + maximum = count; + + return maximum; +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_07.h b/2025.05.23/dist/Krivoruchenko_SK/solve_07.h new file mode 100644 index 0000000..e35b281 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_07.h @@ -0,0 +1,8 @@ +#ifndef SOLVE_H +#define SOLVE_H + +#include "node.h" + +int t7_solve (node *head); + +#endif diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_08.c b/2025.05.23/dist/Krivoruchenko_SK/solve_08.c new file mode 100644 index 0000000..171c5f2 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_08.c @@ -0,0 +1,42 @@ +#include "solve_08.h" +#include "node.h" + +#include +#include + +node * t8_solve (node *head) +{ + node *last = head; + node *curr, *next; + + curr = head->next; + if (!curr) + return head; + + while (strcmp(last->string, curr->string) >= 0) { + free(last->string); + free(last); + + last = curr; + head = curr; + curr = curr->next; + if (!curr) + return head; + } + + for (next = curr->next; next; next = curr->next) + { + if (strcmp(curr->string, next->string) >= 0) { + free(curr->string); + free(curr); + + last->next = next; + } else + last = curr; + + curr = next; + } + + return head; +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_08.h b/2025.05.23/dist/Krivoruchenko_SK/solve_08.h new file mode 100644 index 0000000..3280479 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_08.h @@ -0,0 +1,8 @@ +#ifndef SOLVE_H +#define SOLVE_H + +#include "node.h" + +node * t8_solve (node *head); + +#endif diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_09.c b/2025.05.23/dist/Krivoruchenko_SK/solve_09.c new file mode 100644 index 0000000..091c167 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_09.c @@ -0,0 +1,52 @@ +#include "solve_09.h" +#include "node.h" +#include "io_node.h" + +#include +#include + +node * t9_solve (node *head) +{ + int cmp_last, cmp_next; + node *last, *curr, *next, + *deleted = NULL; + cmp_last=cmp_next=0; + last = head; + if (!last) + return NULL; + curr = last->next; + if (!curr) + return head; + + for (next = curr->next; next; next = curr->next) + { + if (deleted) + cmp_last = strcmp(curr->string, deleted->string); + else + cmp_last = strcmp(curr->string, last->string); + cmp_next = strcmp(curr->string, next->string); // Как происходит обращение в память для структур? + + if ((cmp_last >= 0) && (cmp_next >= 0)) + { + if (deleted) + delete_node(deleted); + deleted = curr; + + last->next = next; + curr = last; + } else + { + if (deleted) + delete_node(deleted); + deleted = NULL; + } + last = curr; + curr = next; + } + + if (deleted) + delete_node(deleted); + + return head; +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_09.h b/2025.05.23/dist/Krivoruchenko_SK/solve_09.h new file mode 100644 index 0000000..30a5df5 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_09.h @@ -0,0 +1,8 @@ +#ifndef SOLVE_H +#define SOLVE_H + +#include "node.h" + +node * t9_solve (node *head); + +#endif diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_10.c b/2025.05.23/dist/Krivoruchenko_SK/solve_10.c new file mode 100644 index 0000000..de4768c --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_10.c @@ -0,0 +1,55 @@ +#include "solve_10.h" +#include "node.h" +#include "io_node.h" + +#include +#include + +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; + curr = start; + } else { + delete_nodes(head, down+1); + head = next; + 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; +} + diff --git a/2025.05.23/dist/Krivoruchenko_SK/solve_10.h b/2025.05.23/dist/Krivoruchenko_SK/solve_10.h new file mode 100644 index 0000000..f080366 --- /dev/null +++ b/2025.05.23/dist/Krivoruchenko_SK/solve_10.h @@ -0,0 +1,8 @@ +#ifndef SOLVE_H +#define SOLVE_H + +#include "node.h" + +node * t10_solve (node *head); + +#endif