From 4c393f4898d6961262ac59d0dcf4427c46778070 Mon Sep 17 00:00:00 2001 From: Artem Date: Tue, 25 Oct 2022 19:42:41 +0300 Subject: [PATCH 1/5] =?UTF-8?q?=D0=9D=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB?= =?UTF-8?q?=20list,=20=D0=BE=D1=81=D1=82=D0=B0=D0=BB=D0=BE=D1=81=D1=8C=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B8=D1=82=D1=8C=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=BE=D1=81=D0=BF=D0=BE=D1=81=D0=BE?= =?UTF-8?q?=D0=B1=D0=BD=D0=BE=D1=81=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sortedList/sortedList.sln | 31 ++++ sortedList/sortedList/list.c | 114 +++++++++++++ sortedList/sortedList/list.h | 20 +++ sortedList/sortedList/main.c | 0 sortedList/sortedList/sortedList.vcxproj | 150 ++++++++++++++++++ .../sortedList/sortedList.vcxproj.filters | 17 ++ 6 files changed, 332 insertions(+) create mode 100644 sortedList/sortedList.sln create mode 100644 sortedList/sortedList/list.c create mode 100644 sortedList/sortedList/list.h create mode 100644 sortedList/sortedList/main.c create mode 100644 sortedList/sortedList/sortedList.vcxproj create mode 100644 sortedList/sortedList/sortedList.vcxproj.filters diff --git a/sortedList/sortedList.sln b/sortedList/sortedList.sln new file mode 100644 index 0000000..c8c0db4 --- /dev/null +++ b/sortedList/sortedList.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sortedList", "sortedList\sortedList.vcxproj", "{C52FFB7D-40D3-4BB3-92B4-A6F3E0B708F9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C52FFB7D-40D3-4BB3-92B4-A6F3E0B708F9}.Debug|x64.ActiveCfg = Debug|x64 + {C52FFB7D-40D3-4BB3-92B4-A6F3E0B708F9}.Debug|x64.Build.0 = Debug|x64 + {C52FFB7D-40D3-4BB3-92B4-A6F3E0B708F9}.Debug|x86.ActiveCfg = Debug|Win32 + {C52FFB7D-40D3-4BB3-92B4-A6F3E0B708F9}.Debug|x86.Build.0 = Debug|Win32 + {C52FFB7D-40D3-4BB3-92B4-A6F3E0B708F9}.Release|x64.ActiveCfg = Release|x64 + {C52FFB7D-40D3-4BB3-92B4-A6F3E0B708F9}.Release|x64.Build.0 = Release|x64 + {C52FFB7D-40D3-4BB3-92B4-A6F3E0B708F9}.Release|x86.ActiveCfg = Release|Win32 + {C52FFB7D-40D3-4BB3-92B4-A6F3E0B708F9}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2314527A-D566-40BA-9919-A77EF21F134B} + EndGlobalSection +EndGlobal diff --git a/sortedList/sortedList/list.c b/sortedList/sortedList/list.c new file mode 100644 index 0000000..9f97146 --- /dev/null +++ b/sortedList/sortedList/list.c @@ -0,0 +1,114 @@ +#include "list.h" +#include + +typedef struct Node { + int value; + int position; + struct Node* next; +} Node; + +struct List { + Node* head; +}; + +bool isEmpty(List* list) { + return list->head == NULL; +} + +int insert(List* list, int value, int position) { + Node* currentNode = list->head; + while (currentNode->position != position) { + if (currentNode->next == NULL) { + return -1; + } + currentNode = currentNode->next; + } + + Node* newNode = calloc(1, sizeof(Node)); + + newNode->value = value; + newNode->position = currentNode->position; + Node* nextNode = currentNode->next; + newNode->next = nextNode; + + currentNode->next = newNode; + while (currentNode != NULL) { + ++currentNode->position; + currentNode = currentNode->next; + } + return 0; +} + +void print(List* list) { + Node* walker = list->head; + int i = 0; + while (walker != NULL) { + printf("%d - %d", i, walker->value); + ++i; + } +} + +int changeNode(List* list, int position, int value) { + Node* walker = list->head; + while (walker->position != position - 1) { + if (walker->next == NULL) { + return -1; + } + walker = walker->next; + } + if (walker->next != NULL) { + walker->next->value = value; + } + return 0; +} + +int clear(List* list) { + int i = 0; + while (!isEmpty(list)) { + if (delete(list, i) == -1) { + return -1; + } + ++i; + } +} + +int delete(List* list, int position) { + if (isEmpty(list)) { + return -1; + } + Node* walker = list->head; + while (walker->position != position - 1) { + if (walker->next == NULL) { + return -1; + } + walker = walker->next; + } + Node* temp = NULL; + if (walker->next != NULL) { + temp = walker->next->next; + free(walker->next); + walker->next = temp; + return 0; + } + free(walker->next); + return 0; +} + +int findNode(List* list, int position, int* errorCode) { + if (isEmpty(list) || position < 0) { + *errorCode = -1; + return 0; + } + Node* temp = list->head; + + for (int i = 1; i <= position; ++i) { + temp = temp->next; + if (temp == NULL) { + *errorCode = -1; + return 0; + } + } + + return temp->value; + +} \ No newline at end of file diff --git a/sortedList/sortedList/list.h b/sortedList/sortedList/list.h new file mode 100644 index 0000000..4b65479 --- /dev/null +++ b/sortedList/sortedList/list.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +typedef struct List List; + +int insert(List* list, int value, int position); + +void print(List* list); + +int delete(List* list, int position); + +int changeNode(List* list, int position, int value); + +bool isEmpty(List* list); + +int clear(List* list); + +int findNode(List* list, int position, int* errorCode); diff --git a/sortedList/sortedList/main.c b/sortedList/sortedList/main.c new file mode 100644 index 0000000..e69de29 diff --git a/sortedList/sortedList/sortedList.vcxproj b/sortedList/sortedList/sortedList.vcxproj new file mode 100644 index 0000000..19f1cba --- /dev/null +++ b/sortedList/sortedList/sortedList.vcxproj @@ -0,0 +1,150 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + 16.0 + Win32Proj + {c52ffb7d-40d3-4bb3-92b4-a6f3e0b708f9} + sortedList + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + diff --git a/sortedList/sortedList/sortedList.vcxproj.filters b/sortedList/sortedList/sortedList.vcxproj.filters new file mode 100644 index 0000000..153170c --- /dev/null +++ b/sortedList/sortedList/sortedList.vcxproj.filters @@ -0,0 +1,17 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + \ No newline at end of file From 30638acd5cb8b162249b353c7ec32cc4936ea894 Mon Sep 17 00:00:00 2001 From: Artem Date: Tue, 25 Oct 2022 23:51:23 +0300 Subject: [PATCH 2/5] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8=20list'a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sortedList/sortedList/list.c | 137 +++++++++--------- sortedList/sortedList/list.h | 11 +- sortedList/sortedList/main.c | 57 ++++++++ sortedList/sortedList/sortedList.vcxproj | 43 +++--- .../sortedList/sortedList.vcxproj.filters | 13 ++ 5 files changed, 165 insertions(+), 96 deletions(-) diff --git a/sortedList/sortedList/list.c b/sortedList/sortedList/list.c index 9f97146..0030384 100644 --- a/sortedList/sortedList/list.c +++ b/sortedList/sortedList/list.c @@ -1,9 +1,9 @@ #include "list.h" #include +#include typedef struct Node { int value; - int position; struct Node* next; } Node; @@ -11,104 +11,105 @@ struct List { Node* head; }; +void print(List* list) { + Node* walker = list->head; + while (walker != NULL) { + printf("%d ", walker->value); + walker = walker->next; + } + printf("\n"); +} + bool isEmpty(List* list) { return list->head == NULL; } -int insert(List* list, int value, int position) { +int insert(List* list, int value) { Node* currentNode = list->head; - while (currentNode->position != position) { - if (currentNode->next == NULL) { + if (currentNode != NULL && currentNode->value >= value) { + Node* newNode = calloc(1, sizeof(Node)); + if (newNode == NULL) { return -1; } - currentNode = currentNode->next; + newNode->value = value; + newNode->next = currentNode; + list->head = newNode; + return 0; } - Node* newNode = calloc(1, sizeof(Node)); - - newNode->value = value; - newNode->position = currentNode->position; - Node* nextNode = currentNode->next; - newNode->next = nextNode; - - currentNode->next = newNode; while (currentNode != NULL) { - ++currentNode->position; + if (currentNode->next == NULL || currentNode->next->value >= value) { + break; + } currentNode = currentNode->next; } - return 0; -} -void print(List* list) { - Node* walker = list->head; - int i = 0; - while (walker != NULL) { - printf("%d - %d", i, walker->value); - ++i; - } -} - -int changeNode(List* list, int position, int value) { - Node* walker = list->head; - while (walker->position != position - 1) { - if (walker->next == NULL) { - return -1; - } - walker = walker->next; + Node* newNode = calloc(1, sizeof(Node)); + if (newNode == NULL) { + return -1; } - if (walker->next != NULL) { - walker->next->value = value; + newNode->value = value; + if (currentNode == NULL) { + list->head = newNode; + return 0; } + newNode->next = currentNode->next; + currentNode->next = newNode; return 0; } -int clear(List* list) { - int i = 0; - while (!isEmpty(list)) { - if (delete(list, i) == -1) { - return -1; +void clearList(List* list) { + while (list->head->next != NULL) { + Node* walker = list->head; + while (walker->next != NULL && walker->next->next != NULL) { + walker = walker->next; } - ++i; + free(walker->next); + walker->next = NULL; } + free(list->head->next); + free(list->head); + list = NULL; } -int delete(List* list, int position) { +int delete(List* list, int value) { + Node* currentNode = list->head; + if (isEmpty(list)) { return -1; } - Node* walker = list->head; - while (walker->position != position - 1) { - if (walker->next == NULL) { - return -1; + if (currentNode->value == value) { + Node* temp = currentNode->next; + free(currentNode); + list->head = temp; + return 0; + } + + while (currentNode != NULL) { + if (currentNode->next == NULL || currentNode->next->value == value) { + if (currentNode->next == NULL && currentNode->value != value) { + return -1; + } + break; } - walker = walker->next; + currentNode = currentNode->next; } + Node* temp = NULL; - if (walker->next != NULL) { - temp = walker->next->next; - free(walker->next); - walker->next = temp; + if (currentNode == NULL) { + return -1; + } + if (currentNode->next != NULL) { + temp = currentNode->next->next; + free(currentNode->next); + currentNode->next = temp; return 0; } - free(walker->next); + free(currentNode->next); return 0; } -int findNode(List* list, int position, int* errorCode) { - if (isEmpty(list) || position < 0) { - *errorCode = -1; - return 0; - } - Node* temp = list->head; - - for (int i = 1; i <= position; ++i) { - temp = temp->next; - if (temp == NULL) { - *errorCode = -1; - return 0; - } - } - - return temp->value; - +List* createList(void) { + List* list = calloc(1, sizeof(List)); + return list; } \ No newline at end of file diff --git a/sortedList/sortedList/list.h b/sortedList/sortedList/list.h index 4b65479..2ec8df9 100644 --- a/sortedList/sortedList/list.h +++ b/sortedList/sortedList/list.h @@ -1,20 +1,17 @@ #pragma once - #include #include typedef struct List List; -int insert(List* list, int value, int position); +int insert(List* list, int value); void print(List* list); -int delete(List* list, int position); - -int changeNode(List* list, int position, int value); +int delete(List* list, int value); bool isEmpty(List* list); -int clear(List* list); +void clearList(List* list); -int findNode(List* list, int position, int* errorCode); +List* createList(void); \ No newline at end of file diff --git a/sortedList/sortedList/main.c b/sortedList/sortedList/main.c index e69de29..60a3a21 100644 --- a/sortedList/sortedList/main.c +++ b/sortedList/sortedList/main.c @@ -0,0 +1,57 @@ +#include +#include +#include "list.h" +#include +#include + +int scanOne() { + int number = 0; + int checkScanf = scanf("%d", &number); + + while (checkScanf != 1) { + while (getchar() != '\n') { + } + + printf("%s", "... \n"); + checkScanf = scanf("%d", &number); + } + + return number; +} + +bool talkWithUser(void) { + List* list = createList(); + printf(" 0 \n 1 \n 2 \n 3 \n"); + int userComand = scanOne(); + while (userComand != 0) { + if (userComand == 1) { + printf(" \n"); + int value = scanOne(); + if (insert(list, value) == -1) { + return false; + } + } + else if (userComand == 2) { + printf(" \n"); + int number = scanOne(); + if (delete(list, number) == -1){ + printf(", !\n"); + } + } else if (userComand == 3) { + print(list); + } + printf(" \n"); + userComand = scanOne(); + } + + clearList(list); + return true; +} + +int main() { + setlocale(LC_ALL, "RUS"); + bool check = talkWithUser(); + if (!check) { + printf(" ...\n"); + } +} \ No newline at end of file diff --git a/sortedList/sortedList/sortedList.vcxproj b/sortedList/sortedList/sortedList.vcxproj index 19f1cba..b776b0f 100644 --- a/sortedList/sortedList/sortedList.vcxproj +++ b/sortedList/sortedList/sortedList.vcxproj @@ -17,7 +17,6 @@ Release x64 - 16.0 @@ -53,25 +52,23 @@ true Unicode - - + + + + + + + + + + + + + - - - - - - - - - - - - - true @@ -85,7 +82,6 @@ false - Level3 @@ -117,7 +113,7 @@ Level3 - true + false _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true @@ -142,9 +138,14 @@ true - - + + + + + + + - + \ No newline at end of file diff --git a/sortedList/sortedList/sortedList.vcxproj.filters b/sortedList/sortedList/sortedList.vcxproj.filters index 153170c..b23289e 100644 --- a/sortedList/sortedList/sortedList.vcxproj.filters +++ b/sortedList/sortedList/sortedList.vcxproj.filters @@ -14,4 +14,17 @@ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + Исходные файлы + + + Исходные файлы + + + + + Исходные файлы + + \ No newline at end of file From 2b609ed0a5799e7d48eb2f47a978b2cea51bc264 Mon Sep 17 00:00:00 2001 From: Artem Date: Wed, 26 Oct 2022 00:31:14 +0300 Subject: [PATCH 3/5] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sortedList/sortedList/list.c | 25 +++++++++++++++++-------- sortedList/sortedList/list.h | 4 +++- sortedList/sortedList/main.c | 19 +++++++++++++++++++ 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/sortedList/sortedList/list.c b/sortedList/sortedList/list.c index 0030384..b62c36c 100644 --- a/sortedList/sortedList/list.c +++ b/sortedList/sortedList/list.c @@ -59,19 +59,28 @@ int insert(List* list, int value) { } void clearList(List* list) { - while (list->head->next != NULL) { - Node* walker = list->head; - while (walker->next != NULL && walker->next->next != NULL) { - walker = walker->next; + if (list->head != NULL) { + while (list->head->next != NULL) { + Node* walker = list->head; + while (walker->next != NULL && walker->next->next != NULL) { + walker = walker->next; + } + free(walker->next); + walker->next = NULL; } - free(walker->next); - walker->next = NULL; + free(list->head->next); + free(list->head); } - free(list->head->next); - free(list->head); list = NULL; } +int top(List* list) { + if (list->head == NULL) { + return -1; + } + return list->head->value; +} + int delete(List* list, int value) { Node* currentNode = list->head; diff --git a/sortedList/sortedList/list.h b/sortedList/sortedList/list.h index 2ec8df9..0b46400 100644 --- a/sortedList/sortedList/list.h +++ b/sortedList/sortedList/list.h @@ -14,4 +14,6 @@ bool isEmpty(List* list); void clearList(List* list); -List* createList(void); \ No newline at end of file +List* createList(void); + +int top(List* list); \ No newline at end of file diff --git a/sortedList/sortedList/main.c b/sortedList/sortedList/main.c index 60a3a21..59e0d70 100644 --- a/sortedList/sortedList/main.c +++ b/sortedList/sortedList/main.c @@ -48,8 +48,27 @@ bool talkWithUser(void) { return true; } +bool tests() { + List* list = createList(); + insert(list, 100); + if (top(list) != 100) { + return false; + } + delete(list, 100); + if (top(list) != -1) { + return false; + } + return true; +} + int main() { setlocale(LC_ALL, "RUS"); + if (tests()) { + printf(" \n"); + } else { + printf("- ...\n"); + return 0; + } bool check = talkWithUser(); if (!check) { printf(" ...\n"); From d4ecd22bbc700e6a787e57f7a3d87c49026a809f Mon Sep 17 00:00:00 2001 From: Palezehvat <114094069+Palezehvat@users.noreply.github.com> Date: Fri, 18 Nov 2022 14:46:54 +0300 Subject: [PATCH 4/5] Delete HomeworksAccept directory --- HomeworksAccept/homework21.09/read.me | 1 - HomeworksAccept/homework28.09/read.me | 1 - HomeworksAccept/read.me | 1 - 3 files changed, 3 deletions(-) delete mode 100644 HomeworksAccept/homework21.09/read.me delete mode 100644 HomeworksAccept/homework28.09/read.me delete mode 100644 HomeworksAccept/read.me diff --git a/HomeworksAccept/homework21.09/read.me b/HomeworksAccept/homework21.09/read.me deleted file mode 100644 index 5e4d090..0000000 --- a/HomeworksAccept/homework21.09/read.me +++ /dev/null @@ -1 +0,0 @@ -3 домашка diff --git a/HomeworksAccept/homework28.09/read.me b/HomeworksAccept/homework28.09/read.me deleted file mode 100644 index 5061ad0..0000000 --- a/HomeworksAccept/homework28.09/read.me +++ /dev/null @@ -1 +0,0 @@ -4 домашка diff --git a/HomeworksAccept/read.me b/HomeworksAccept/read.me deleted file mode 100644 index 1773bf8..0000000 --- a/HomeworksAccept/read.me +++ /dev/null @@ -1 +0,0 @@ -Здесь представлены домашнии работы, прошедшии проверку From cc495beb9195260efdeb3d7c4f20ec832e34be88 Mon Sep 17 00:00:00 2001 From: Artem Date: Fri, 23 Dec 2022 12:25:14 +0300 Subject: [PATCH 5/5] =?UTF-8?q?=D1=80=D0=B5=D0=B2=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sortedList/sortedList/list.c | 35 ++++++++++++++++------------------- sortedList/sortedList/list.h | 2 +- sortedList/sortedList/main.c | 7 +++++-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/sortedList/sortedList/list.c b/sortedList/sortedList/list.c index b62c36c..72e7ed5 100644 --- a/sortedList/sortedList/list.c +++ b/sortedList/sortedList/list.c @@ -25,13 +25,14 @@ bool isEmpty(List* list) { } int insert(List* list, int value) { + Node* newNode = calloc(1, sizeof(Node)); + if (newNode == NULL) { + return -1; + } + newNode->value = value; Node* currentNode = list->head; + if (currentNode != NULL && currentNode->value >= value) { - Node* newNode = calloc(1, sizeof(Node)); - if (newNode == NULL) { - return -1; - } - newNode->value = value; newNode->next = currentNode; list->head = newNode; return 0; @@ -44,11 +45,6 @@ int insert(List* list, int value) { currentNode = currentNode->next; } - Node* newNode = calloc(1, sizeof(Node)); - if (newNode == NULL) { - return -1; - } - newNode->value = value; if (currentNode == NULL) { list->head = newNode; return 0; @@ -58,20 +54,20 @@ int insert(List* list, int value) { return 0; } -void clearList(List* list) { - if (list->head != NULL) { - while (list->head->next != NULL) { - Node* walker = list->head; +void clearList(List** list) { + if ((*list)->head != NULL) { + while ((*list)->head->next != NULL) { + Node* walker = (*list)->head; while (walker->next != NULL && walker->next->next != NULL) { walker = walker->next; } free(walker->next); walker->next = NULL; } - free(list->head->next); - free(list->head); + free((*list)->head->next); + free((*list)->head); } - list = NULL; + *list = NULL; } int top(List* list) { @@ -104,16 +100,17 @@ int delete(List* list, int value) { currentNode = currentNode->next; } - Node* temp = NULL; if (currentNode == NULL) { return -1; } + if (currentNode->next != NULL) { - temp = currentNode->next->next; + Node* temp = currentNode->next->next; free(currentNode->next); currentNode->next = temp; return 0; } + free(currentNode->next); return 0; } diff --git a/sortedList/sortedList/list.h b/sortedList/sortedList/list.h index 0b46400..5eb6292 100644 --- a/sortedList/sortedList/list.h +++ b/sortedList/sortedList/list.h @@ -12,7 +12,7 @@ int delete(List* list, int value); bool isEmpty(List* list); -void clearList(List* list); +void clearList(List** list); List* createList(void); diff --git a/sortedList/sortedList/main.c b/sortedList/sortedList/main.c index 59e0d70..8123127 100644 --- a/sortedList/sortedList/main.c +++ b/sortedList/sortedList/main.c @@ -34,7 +34,7 @@ bool talkWithUser(void) { else if (userComand == 2) { printf(" \n"); int number = scanOne(); - if (delete(list, number) == -1){ + if (delete(list, number) == -1) { printf(", !\n"); } } else if (userComand == 3) { @@ -44,7 +44,7 @@ bool talkWithUser(void) { userComand = scanOne(); } - clearList(list); + clearList(&list); return true; } @@ -52,12 +52,15 @@ bool tests() { List* list = createList(); insert(list, 100); if (top(list) != 100) { + clearList(&list); return false; } delete(list, 100); if (top(list) != -1) { + clearList(&list); return false; } + clearList(&list); return true; }