From 67bfd7d2d59c00b04daa0644df2a889e599c5310 Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 17 Oct 2022 15:16:11 +0300 Subject: [PATCH 01/19] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sortAndFilesAndModules/test.txt | 4 + queue/queue.sln | 31 ++++ queue/queue/main.c | 106 +++++++++++++ queue/queue/queue.vcxproj | 147 ++++++++++++++++++ queue/queue/queue.vcxproj.filters | 22 +++ stack/stack.sln | 31 ++++ stack/stack/main.c | 59 +++++++ stack/stack/stack.vcxproj | 147 ++++++++++++++++++ stack/stack/stack.vcxproj.filters | 22 +++ 9 files changed, 569 insertions(+) create mode 100644 ModulesAndFiles/sortAndFilesAndModules/sortAndFilesAndModules/test.txt create mode 100644 queue/queue.sln create mode 100644 queue/queue/main.c create mode 100644 queue/queue/queue.vcxproj create mode 100644 queue/queue/queue.vcxproj.filters create mode 100644 stack/stack.sln create mode 100644 stack/stack/main.c create mode 100644 stack/stack/stack.vcxproj create mode 100644 stack/stack/stack.vcxproj.filters diff --git a/ModulesAndFiles/sortAndFilesAndModules/sortAndFilesAndModules/test.txt b/ModulesAndFiles/sortAndFilesAndModules/sortAndFilesAndModules/test.txt new file mode 100644 index 0000000..2fb6348 --- /dev/null +++ b/ModulesAndFiles/sortAndFilesAndModules/sortAndFilesAndModules/test.txt @@ -0,0 +1,4 @@ +3 +222 +22 +2222 \ No newline at end of file diff --git a/queue/queue.sln b/queue/queue.sln new file mode 100644 index 0000000..6ce5b3f --- /dev/null +++ b/queue/queue.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}") = "queue", "queue\queue.vcxproj", "{E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}" +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 + {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Debug|x64.ActiveCfg = Debug|x64 + {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Debug|x64.Build.0 = Debug|x64 + {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Debug|x86.ActiveCfg = Debug|Win32 + {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Debug|x86.Build.0 = Debug|Win32 + {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Release|x64.ActiveCfg = Release|x64 + {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Release|x64.Build.0 = Release|x64 + {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Release|x86.ActiveCfg = Release|Win32 + {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BF103872-E776-4F20-8B62-9EF45E3E5ECA} + EndGlobalSection +EndGlobal diff --git a/queue/queue/main.c b/queue/queue/main.c new file mode 100644 index 0000000..9005746 --- /dev/null +++ b/queue/queue/main.c @@ -0,0 +1,106 @@ +#include +#include +#include + +typedef struct QueueElement { + int value; + struct QueueElement* next; +}QueueElement; + +typedef struct Queue { + struct QueueElement* head; + struct QueueElement* tail; +}Queue; + +int enqueue(Queue* queue, int value) { + QueueElement* temp = malloc(sizeof(QueueElement)); + if (temp == NULL) { + printf(", "); + return -1; + } + + temp->value = value; + temp->next = NULL; + + if (queue->tail == NULL) { + queue->head = temp; + queue->tail = temp; + return 0; + } + + queue->tail->next = temp; + queue->tail = temp; + + return 0; +} + +int dequeue(Queue* queue, int* errorCode) { + if (queue->head == NULL){ + if (errorCode != NULL) { + *errorCode = -1; + return 0; + } + } + if (errorCode != NULL) { + *errorCode = 1; + } + + int value = queue->head->value; + + QueueElement* next = queue->head->next; + free(queue->head); + queue->head = next; + if (queue->head == NULL) { + queue->tail = NULL; + } + return value; +} + +bool isEmpty(Queue queue) { + return queue.head == NULL; +} + +void clear(Queue* queue) { + while (!isEmpty(*queue)) { + dequeue(queue, NULL); + } +} + +int main() { + Queue queue = { .head = NULL, .tail = NULL }; + int errorCode = 0; + + if (enqueue(&queue, 100) == -1) { + printf(" ...\n"); + return -1; + } + if (queue.tail == NULL) { + printf(" ...\n"); + return -1; + } + if (enqueue(&queue, 200) == -1) { + printf(" ...\n"); + return -1; + } + if (queue.tail == NULL) { + printf(" ...\n"); + return -1; + } + if (enqueue(&queue, 300) == -1) { + printf(" ...\n"); + return -1; + } + if (queue.tail == NULL) { + printf(" ...\n"); + return -1; + } + if (dequeue(&queue, 300) == -1) { + printf(" ...\n"); + return -1; + } + if (queue.tail == NULL) { + printf(" ...\n"); + return -1; + } + printf("%d", queue.tail->value); +} \ No newline at end of file diff --git a/queue/queue/queue.vcxproj b/queue/queue/queue.vcxproj new file mode 100644 index 0000000..a687029 --- /dev/null +++ b/queue/queue/queue.vcxproj @@ -0,0 +1,147 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {e2ecf2c5-52d3-4104-87d4-1e6c4e70339c} + queue + 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 + false + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/queue/queue/queue.vcxproj.filters b/queue/queue/queue.vcxproj.filters new file mode 100644 index 0000000..669bc4e --- /dev/null +++ b/queue/queue/queue.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {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 diff --git a/stack/stack.sln b/stack/stack.sln new file mode 100644 index 0000000..c1adceb --- /dev/null +++ b/stack/stack.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}") = "stack", "stack\stack.vcxproj", "{5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}" +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 + {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Debug|x64.ActiveCfg = Debug|x64 + {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Debug|x64.Build.0 = Debug|x64 + {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Debug|x86.ActiveCfg = Debug|Win32 + {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Debug|x86.Build.0 = Debug|Win32 + {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Release|x64.ActiveCfg = Release|x64 + {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Release|x64.Build.0 = Release|x64 + {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Release|x86.ActiveCfg = Release|Win32 + {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {072424DC-5180-48FE-9111-00078E674BC4} + EndGlobalSection +EndGlobal diff --git a/stack/stack/main.c b/stack/stack/main.c new file mode 100644 index 0000000..a977d59 --- /dev/null +++ b/stack/stack/main.c @@ -0,0 +1,59 @@ +#include +#include +#include + +typedef struct ElementStack { + struct ElementStack* next; + int value; +} ElementStack; + +int pushElements(ElementStack** head, int value) { + ElementStack *temp = malloc(sizeof(ElementStack)); + if (temp == NULL) { + return -1; + } + temp->value = value; + temp->next = *head; + + *head = temp; + return 0; +} + +bool isEmpty(ElementStack* head) { + return head == NULL; +} + +void clear(ElementStack** head) { + while (!isEmpty(*head)) { + popElements(head, NULL); + } +} + +int popElements(ElementStack** head, int* errorCode) { + if (*head == NULL && errorCode != NULL) { + *errorCode = -1; + return -1; + } + *errorCode = 0; + + int value = (*head)->value; + + ElementStack* temp = (*head)->next; + free(*head); + *head = temp; + return value; +} + +int main() { + ElementStack *head = NULL; + int isCorrect = pushElements(&head, 100) == -1; + if (isCorrect == -1){ + printf(" \n"); + } + isCorrect = pushElements(&head, 200) == -1; + if (isCorrect == -1) { + printf(" \n"); + } + int errorCode = 0; + printf("%d %d", popElements(&head, &errorCode)); +} \ No newline at end of file diff --git a/stack/stack/stack.vcxproj b/stack/stack/stack.vcxproj new file mode 100644 index 0000000..d2378db --- /dev/null +++ b/stack/stack/stack.vcxproj @@ -0,0 +1,147 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {5e8d1f3d-66aa-42e9-99ec-855fdd1422b0} + stack + 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 + false + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/stack/stack/stack.vcxproj.filters b/stack/stack/stack.vcxproj.filters new file mode 100644 index 0000000..669bc4e --- /dev/null +++ b/stack/stack/stack.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {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 f618c8e5dbce09d4d66d15d6efbd8cf8eb9044ce Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 17 Oct 2022 15:21:42 +0300 Subject: [PATCH 02/19] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postfixCalculator/postfixCalculator.sln | 31 ++++ postfixCalculator/postfixCalculator/main.c | 0 .../postfixCalculator.vcxproj | 150 ++++++++++++++++++ .../postfixCalculator.vcxproj.filters | 17 ++ postfixCalculator/postfixCalculator/stack.h | 0 5 files changed, 198 insertions(+) create mode 100644 postfixCalculator/postfixCalculator.sln create mode 100644 postfixCalculator/postfixCalculator/main.c create mode 100644 postfixCalculator/postfixCalculator/postfixCalculator.vcxproj create mode 100644 postfixCalculator/postfixCalculator/postfixCalculator.vcxproj.filters create mode 100644 postfixCalculator/postfixCalculator/stack.h diff --git a/postfixCalculator/postfixCalculator.sln b/postfixCalculator/postfixCalculator.sln new file mode 100644 index 0000000..0b3ac41 --- /dev/null +++ b/postfixCalculator/postfixCalculator.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}") = "postfixCalculator", "postfixCalculator\postfixCalculator.vcxproj", "{8C7F0589-31A5-4678-A9C7-6C64BC73BE70}" +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 + {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Debug|x64.ActiveCfg = Debug|x64 + {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Debug|x64.Build.0 = Debug|x64 + {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Debug|x86.ActiveCfg = Debug|Win32 + {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Debug|x86.Build.0 = Debug|Win32 + {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Release|x64.ActiveCfg = Release|x64 + {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Release|x64.Build.0 = Release|x64 + {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Release|x86.ActiveCfg = Release|Win32 + {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0E76BB72-D754-45D2-AB98-9D4A536995AF} + EndGlobalSection +EndGlobal diff --git a/postfixCalculator/postfixCalculator/main.c b/postfixCalculator/postfixCalculator/main.c new file mode 100644 index 0000000..e69de29 diff --git a/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj b/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj new file mode 100644 index 0000000..b151cec --- /dev/null +++ b/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj @@ -0,0 +1,150 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + 16.0 + Win32Proj + {8c7f0589-31a5-4678-a9c7-6c64bc73be70} + postfixCalculator + 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/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj.filters b/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj.filters new file mode 100644 index 0000000..153170c --- /dev/null +++ b/postfixCalculator/postfixCalculator/postfixCalculator.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 diff --git a/postfixCalculator/postfixCalculator/stack.h b/postfixCalculator/postfixCalculator/stack.h new file mode 100644 index 0000000..e69de29 From 02ec3166cf9854818b6d766873d06d265383b4fe Mon Sep 17 00:00:00 2001 From: Palezehvat <114094069+Palezehvat@users.noreply.github.com> Date: Mon, 17 Oct 2022 15:22:45 +0300 Subject: [PATCH 03/19] 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 b701e01ae056b00029e6a2979bf684d3d45f11f0 Mon Sep 17 00:00:00 2001 From: Palezehvat <114094069+Palezehvat@users.noreply.github.com> Date: Mon, 17 Oct 2022 15:22:55 +0300 Subject: [PATCH 04/19] Delete ModulesAndFiles/sortAndFilesAndModules/sortAndFilesAndModules directory --- .../sortAndFilesAndModules/sortAndFilesAndModules/test.txt | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 ModulesAndFiles/sortAndFilesAndModules/sortAndFilesAndModules/test.txt diff --git a/ModulesAndFiles/sortAndFilesAndModules/sortAndFilesAndModules/test.txt b/ModulesAndFiles/sortAndFilesAndModules/sortAndFilesAndModules/test.txt deleted file mode 100644 index 2fb6348..0000000 --- a/ModulesAndFiles/sortAndFilesAndModules/sortAndFilesAndModules/test.txt +++ /dev/null @@ -1,4 +0,0 @@ -3 -222 -22 -2222 \ No newline at end of file From e28b6e29b8622ecb0cac80a51b64cbf89e1f23cb Mon Sep 17 00:00:00 2001 From: Palezehvat <114094069+Palezehvat@users.noreply.github.com> Date: Mon, 17 Oct 2022 15:23:07 +0300 Subject: [PATCH 05/19] Delete queue directory --- queue/queue.sln | 31 ------- queue/queue/main.c | 106 --------------------- queue/queue/queue.vcxproj | 147 ------------------------------ queue/queue/queue.vcxproj.filters | 22 ----- 4 files changed, 306 deletions(-) delete mode 100644 queue/queue.sln delete mode 100644 queue/queue/main.c delete mode 100644 queue/queue/queue.vcxproj delete mode 100644 queue/queue/queue.vcxproj.filters diff --git a/queue/queue.sln b/queue/queue.sln deleted file mode 100644 index 6ce5b3f..0000000 --- a/queue/queue.sln +++ /dev/null @@ -1,31 +0,0 @@ - -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}") = "queue", "queue\queue.vcxproj", "{E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}" -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 - {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Debug|x64.ActiveCfg = Debug|x64 - {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Debug|x64.Build.0 = Debug|x64 - {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Debug|x86.ActiveCfg = Debug|Win32 - {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Debug|x86.Build.0 = Debug|Win32 - {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Release|x64.ActiveCfg = Release|x64 - {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Release|x64.Build.0 = Release|x64 - {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Release|x86.ActiveCfg = Release|Win32 - {E2ECF2C5-52D3-4104-87D4-1E6C4E70339C}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {BF103872-E776-4F20-8B62-9EF45E3E5ECA} - EndGlobalSection -EndGlobal diff --git a/queue/queue/main.c b/queue/queue/main.c deleted file mode 100644 index 9005746..0000000 --- a/queue/queue/main.c +++ /dev/null @@ -1,106 +0,0 @@ -#include -#include -#include - -typedef struct QueueElement { - int value; - struct QueueElement* next; -}QueueElement; - -typedef struct Queue { - struct QueueElement* head; - struct QueueElement* tail; -}Queue; - -int enqueue(Queue* queue, int value) { - QueueElement* temp = malloc(sizeof(QueueElement)); - if (temp == NULL) { - printf(", "); - return -1; - } - - temp->value = value; - temp->next = NULL; - - if (queue->tail == NULL) { - queue->head = temp; - queue->tail = temp; - return 0; - } - - queue->tail->next = temp; - queue->tail = temp; - - return 0; -} - -int dequeue(Queue* queue, int* errorCode) { - if (queue->head == NULL){ - if (errorCode != NULL) { - *errorCode = -1; - return 0; - } - } - if (errorCode != NULL) { - *errorCode = 1; - } - - int value = queue->head->value; - - QueueElement* next = queue->head->next; - free(queue->head); - queue->head = next; - if (queue->head == NULL) { - queue->tail = NULL; - } - return value; -} - -bool isEmpty(Queue queue) { - return queue.head == NULL; -} - -void clear(Queue* queue) { - while (!isEmpty(*queue)) { - dequeue(queue, NULL); - } -} - -int main() { - Queue queue = { .head = NULL, .tail = NULL }; - int errorCode = 0; - - if (enqueue(&queue, 100) == -1) { - printf(" ...\n"); - return -1; - } - if (queue.tail == NULL) { - printf(" ...\n"); - return -1; - } - if (enqueue(&queue, 200) == -1) { - printf(" ...\n"); - return -1; - } - if (queue.tail == NULL) { - printf(" ...\n"); - return -1; - } - if (enqueue(&queue, 300) == -1) { - printf(" ...\n"); - return -1; - } - if (queue.tail == NULL) { - printf(" ...\n"); - return -1; - } - if (dequeue(&queue, 300) == -1) { - printf(" ...\n"); - return -1; - } - if (queue.tail == NULL) { - printf(" ...\n"); - return -1; - } - printf("%d", queue.tail->value); -} \ No newline at end of file diff --git a/queue/queue/queue.vcxproj b/queue/queue/queue.vcxproj deleted file mode 100644 index a687029..0000000 --- a/queue/queue/queue.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {e2ecf2c5-52d3-4104-87d4-1e6c4e70339c} - queue - 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 - false - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/queue/queue/queue.vcxproj.filters b/queue/queue/queue.vcxproj.filters deleted file mode 100644 index 669bc4e..0000000 --- a/queue/queue/queue.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {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 1495402f6451bc56cf4d6a14dd6289ed2f102da9 Mon Sep 17 00:00:00 2001 From: Palezehvat <114094069+Palezehvat@users.noreply.github.com> Date: Mon, 17 Oct 2022 15:23:15 +0300 Subject: [PATCH 06/19] Delete stack directory --- stack/stack.sln | 31 ------- stack/stack/main.c | 59 ------------ stack/stack/stack.vcxproj | 147 ------------------------------ stack/stack/stack.vcxproj.filters | 22 ----- 4 files changed, 259 deletions(-) delete mode 100644 stack/stack.sln delete mode 100644 stack/stack/main.c delete mode 100644 stack/stack/stack.vcxproj delete mode 100644 stack/stack/stack.vcxproj.filters diff --git a/stack/stack.sln b/stack/stack.sln deleted file mode 100644 index c1adceb..0000000 --- a/stack/stack.sln +++ /dev/null @@ -1,31 +0,0 @@ - -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}") = "stack", "stack\stack.vcxproj", "{5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}" -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 - {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Debug|x64.ActiveCfg = Debug|x64 - {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Debug|x64.Build.0 = Debug|x64 - {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Debug|x86.ActiveCfg = Debug|Win32 - {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Debug|x86.Build.0 = Debug|Win32 - {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Release|x64.ActiveCfg = Release|x64 - {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Release|x64.Build.0 = Release|x64 - {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Release|x86.ActiveCfg = Release|Win32 - {5E8D1F3D-66AA-42E9-99EC-855FDD1422B0}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {072424DC-5180-48FE-9111-00078E674BC4} - EndGlobalSection -EndGlobal diff --git a/stack/stack/main.c b/stack/stack/main.c deleted file mode 100644 index a977d59..0000000 --- a/stack/stack/main.c +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include - -typedef struct ElementStack { - struct ElementStack* next; - int value; -} ElementStack; - -int pushElements(ElementStack** head, int value) { - ElementStack *temp = malloc(sizeof(ElementStack)); - if (temp == NULL) { - return -1; - } - temp->value = value; - temp->next = *head; - - *head = temp; - return 0; -} - -bool isEmpty(ElementStack* head) { - return head == NULL; -} - -void clear(ElementStack** head) { - while (!isEmpty(*head)) { - popElements(head, NULL); - } -} - -int popElements(ElementStack** head, int* errorCode) { - if (*head == NULL && errorCode != NULL) { - *errorCode = -1; - return -1; - } - *errorCode = 0; - - int value = (*head)->value; - - ElementStack* temp = (*head)->next; - free(*head); - *head = temp; - return value; -} - -int main() { - ElementStack *head = NULL; - int isCorrect = pushElements(&head, 100) == -1; - if (isCorrect == -1){ - printf(" \n"); - } - isCorrect = pushElements(&head, 200) == -1; - if (isCorrect == -1) { - printf(" \n"); - } - int errorCode = 0; - printf("%d %d", popElements(&head, &errorCode)); -} \ No newline at end of file diff --git a/stack/stack/stack.vcxproj b/stack/stack/stack.vcxproj deleted file mode 100644 index d2378db..0000000 --- a/stack/stack/stack.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {5e8d1f3d-66aa-42e9-99ec-855fdd1422b0} - stack - 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 - false - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/stack/stack/stack.vcxproj.filters b/stack/stack/stack.vcxproj.filters deleted file mode 100644 index 669bc4e..0000000 --- a/stack/stack/stack.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {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 7afad16c7585183548da4df23e78de4370feb81c Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 17 Oct 2022 15:31:08 +0300 Subject: [PATCH 07/19] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=81=D1=82=D0=B5=D0=BA,=20=D0=BD=D0=B0=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=B0=D0=BD=D0=BD=D1=8B=D0=B9=20=D0=BD=D0=B0=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B5=D0=B4=D1=8B=D0=B4=D1=83=D1=88=D0=B5=D0=BC=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BD=D1=8F=D1=82=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postfixCalculator/postfixCalculator/stack.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 postfixCalculator/postfixCalculator/stack.c diff --git a/postfixCalculator/postfixCalculator/stack.c b/postfixCalculator/postfixCalculator/stack.c new file mode 100644 index 0000000..e69de29 From d3cb32f69272fe1596ee9929e88798e1cff1f9ac Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 17 Oct 2022 15:34:19 +0300 Subject: [PATCH 08/19] =?UTF-8?q?=D0=A1=D0=BE=D1=85=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F,=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D1=82=D0=BE?= =?UTF-8?q?=D1=87=D0=BD=D0=BE=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postfixCalculator/postfixCalculator/main.c | 5 +++ postfixCalculator/postfixCalculator/stack.c | 41 +++++++++++++++++++++ postfixCalculator/postfixCalculator/stack.h | 16 ++++++++ 3 files changed, 62 insertions(+) diff --git a/postfixCalculator/postfixCalculator/main.c b/postfixCalculator/postfixCalculator/main.c index e69de29..a7a90d6 100644 --- a/postfixCalculator/postfixCalculator/main.c +++ b/postfixCalculator/postfixCalculator/main.c @@ -0,0 +1,5 @@ +#include + +int main() { + +} \ No newline at end of file diff --git a/postfixCalculator/postfixCalculator/stack.c b/postfixCalculator/postfixCalculator/stack.c index e69de29..250483e 100644 --- a/postfixCalculator/postfixCalculator/stack.c +++ b/postfixCalculator/postfixCalculator/stack.c @@ -0,0 +1,41 @@ +#include "stack.h" +#include +#include +#include + +int pushElements(ElementStack** head, int value) { + ElementStack* temp = malloc(sizeof(ElementStack)); + if (temp == NULL) { + return -1; + } + temp->value = value; + temp->next = *head; + + *head = temp; + return 0; +} + +bool isEmpty(ElementStack* head) { + return head == NULL; +} + +void clear(ElementStack** head) { + while (!isEmpty(*head)) { + popElements(head, NULL); + } +} + +int popElements(ElementStack** head, int* errorCode) { + if (*head == NULL && errorCode != NULL) { + *errorCode = -1; + return -1; + } + *errorCode = 0; + + int value = (*head)->value; + + ElementStack* temp = (*head)->next; + free(*head); + *head = temp; + return value; +} \ No newline at end of file diff --git a/postfixCalculator/postfixCalculator/stack.h b/postfixCalculator/postfixCalculator/stack.h index e69de29..360cd6f 100644 --- a/postfixCalculator/postfixCalculator/stack.h +++ b/postfixCalculator/postfixCalculator/stack.h @@ -0,0 +1,16 @@ +#ifndef STACK_H_ +#define STACK_H_ +#include + +typedef struct ElementStack { + struct ElementStack* next; + int value; +} ElementStack; + +int pushElements(ElementStack** head, int value); +bool isEmpty(ElementStack* head); +void clear(ElementStack** head); +int popElements(ElementStack** head, int* errorCode); + +#endif // !STACK_H_ + From 520737acb37d44b8bff5e70198f413b30f9f5fb2 Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 17 Oct 2022 15:38:16 +0300 Subject: [PATCH 09/19] =?UTF-8?q?=D0=9A=D0=BE=D0=BC=D0=BF=D0=B8=D0=BB?= =?UTF-8?q?=D1=8F=D1=82=D0=BE=D1=80=20=D1=80=D1=83=D0=B3=D0=B0=D0=BB=D1=81?= =?UTF-8?q?=D1=8F=20=D0=BD=D0=B0=20=D1=80=D0=B0=D0=B7=D1=8B=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=83=D1=81?= =?UTF-8?q?=D1=82=D0=BE=D0=B3=D0=BE=20=D1=83=D0=BA=D0=B0=D0=B7=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8F,=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postfixCalculator/postfixCalculator/stack.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/postfixCalculator/postfixCalculator/stack.c b/postfixCalculator/postfixCalculator/stack.c index 250483e..f7351b6 100644 --- a/postfixCalculator/postfixCalculator/stack.c +++ b/postfixCalculator/postfixCalculator/stack.c @@ -26,11 +26,15 @@ void clear(ElementStack** head) { } int popElements(ElementStack** head, int* errorCode) { - if (*head == NULL && errorCode != NULL) { + if (*head == NULL) { + if (errorCode != NULL) { *errorCode = -1; + } return -1; } - *errorCode = 0; + if (errorCode != NULL) { + *errorCode = 0; + } int value = (*head)->value; From 53bdfefdf215eb8d4f77c445fd1aab8162cd78f1 Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 17 Oct 2022 17:53:01 +0300 Subject: [PATCH 10/19] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D1=82=D0=B8=20=D1=81?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D1=84=D1=83=D0=BD=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D1=8E=20=D0=BF=D1=80=D0=B8=D0=B5=D0=BC=D0=B0=20=D1=87?= =?UTF-8?q?=D0=B8=D1=81=D0=B5=D0=BB=20=D0=B8=20=D0=B4=D0=B5=D0=B9=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=B8=D0=B9=20=D0=BD=D0=B0=D0=B4=20=D0=BD=D0=B8?= =?UTF-8?q?=D0=BC=D0=B8=20=D0=BE=D1=82=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postfixCalculator/postfixCalculator/main.c | 49 +++++++++++++++++++ .../postfixCalculator.vcxproj | 43 ++++++++-------- .../postfixCalculator.vcxproj.filters | 13 +++++ 3 files changed, 84 insertions(+), 21 deletions(-) diff --git a/postfixCalculator/postfixCalculator/main.c b/postfixCalculator/postfixCalculator/main.c index a7a90d6..0d2fe96 100644 --- a/postfixCalculator/postfixCalculator/main.c +++ b/postfixCalculator/postfixCalculator/main.c @@ -1,5 +1,54 @@ #include +#include "stack.h" +#include +#include +#include + +int scanOne(); + +void elementsForStack(char stringOfActions[]) { + size_t sizeString = strlen(stringOfActions); + size_t i = 0; + while(i < sizeString) { + int number = 0; + int multiplier = 1; + while (stringOfActions[i] >= '0' && stringOfActions[i] <= '9') { + number *= multiplier; + number += ((int)stringOfActions[i] - 48); + multiplier = 10; + ++i; + } + printf("%d", number); + } +} int main() { + setlocale(LC_ALL, "RUS"); + char stringOfActions[100] = {'\0'}; + printf(" , 100 \n"); + int checkScanf = scanf("%s", &stringOfActions); + while (checkScanf != 1) + { + while (getchar() != '\n') { + } + printf("%s", "... - . \n"); + int checkScanf = scanf("%s", &stringOfActions); + } + elementsForStack(stringOfActions); + +} + +int scanOne() { + int number = 0; + int checkScanf = scanf("%d", &number); + printf("2 %c", checkScanf); + while (checkScanf != 1) { + while (getchar() != '\n') { + } + + printf("%s", "... \n"); + checkScanf = scanf("%d", &number); + } + return number; } \ No newline at end of file diff --git a/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj b/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj index b151cec..8d1e185 100644 --- a/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj +++ b/postfixCalculator/postfixCalculator/postfixCalculator.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/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj.filters b/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj.filters index 153170c..6498e61 100644 --- a/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj.filters +++ b/postfixCalculator/postfixCalculator/postfixCalculator.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 5df6e8b88542a2c3cadbd13170471a0d00379d54 Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 17 Oct 2022 19:17:04 +0300 Subject: [PATCH 11/19] =?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=20=D1=81=D0=BB=D0=BE?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F,=20=D1=83=D0=BC=D0=BD=D0=BE?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F,=20=D0=B2=D1=8B=D1=87=D0=B8?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=B8=D1=8F,=20=D0=B4=D0=B5=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F,=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D1=8F=D1=8E=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postfixCalculator/postfixCalculator/main.c | 149 +++++++++++++++----- postfixCalculator/postfixCalculator/stack.c | 5 +- 2 files changed, 117 insertions(+), 37 deletions(-) diff --git a/postfixCalculator/postfixCalculator/main.c b/postfixCalculator/postfixCalculator/main.c index 0d2fe96..9ae17a6 100644 --- a/postfixCalculator/postfixCalculator/main.c +++ b/postfixCalculator/postfixCalculator/main.c @@ -4,51 +4,134 @@ #include #include -int scanOne(); +int plus(ElementStack* buffer, int* errorCode) { + if (buffer == NULL) { + *errorCode = 0; + return 0; + } + int firstNumber = popElements(&buffer, &errorCode); + if (errorCode == 0) { + return 0; + } + int secondNumber = popElements(&buffer, &errorCode); + if (errorCode == 0) { + return 0; + } + return firstNumber + secondNumber; +} + +int minus(ElementStack* buffer, int* errorCode) { + if (buffer == NULL) { + *errorCode = 0; + return 0; + } + int firstNumber = popElements(&buffer, &errorCode); + if (errorCode == 0) { + return 0; + } + int secondNumber = popElements(&buffer, &errorCode); + if (errorCode == 0) { + return 0; + } + return secondNumber - firstNumber; +} + +int multiply(ElementStack* buffer, int* errorCode) { + if (buffer == NULL) { + *errorCode = 0; + return 0; + } + int firstNumber = popElements(&buffer, &errorCode); + if (errorCode == 0) { + return 0; + } + int secondNumber = popElements(&buffer, &errorCode); + if (errorCode == 0) { + return 0; + } + return firstNumber * secondNumber; +} -void elementsForStack(char stringOfActions[]) { +int divide(ElementStack* buffer, int* errorCode) { + if (buffer == NULL) { + *errorCode = 0; + return 0; + } + int firstNumber = popElements(&buffer, &errorCode); + if (errorCode == 0) { + return 0; + } + int secondNumber = popElements(&buffer, &errorCode); + if (errorCode == 0) { + return 0; + } + return secondNumber / firstNumber; +} + +int elementsForStack(char stringOfActions[], int* errorCode) { size_t sizeString = strlen(stringOfActions); size_t i = 0; + ElementStack* buffer; while(i < sizeString) { int number = 0; int multiplier = 1; - while (stringOfActions[i] >= '0' && stringOfActions[i] <= '9') { - number *= multiplier; - number += ((int)stringOfActions[i] - 48); - multiplier = 10; - ++i; + if (stringOfActions[i] >= '0' && stringOfActions[i] <= '9') { + while (stringOfActions[i] >= '0' && stringOfActions[i] <= '9') { + number *= multiplier; + number += ((int)stringOfActions[i] - 48); + multiplier = 10; + ++i; + } + pushElements(&buffer, number); + } else { + if (stringOfActions[i] == '*') { + int numberAfter = multiply(buffer, errorCode); + if (*errorCode == 0) { + return 0; + } + pushElements(&buffer, numberAfter); + } + else if (stringOfActions[i] == '+') { + int numberAfter = plus(buffer, errorCode); + if (*errorCode == 0) { + return 0; + } + pushElements(&buffer, numberAfter); + } + else if (stringOfActions[i] == '-') { + int numberAfter = minus(buffer, errorCode); + if (*errorCode == 0) { + return 0; + } + pushElements(&buffer, numberAfter); + } + else if (stringOfActions[i] == '\\') { + int numberAfter = divide(buffer, errorCode); + if (*errorCode == 0) { + return 0; + } + pushElements(&buffer, numberAfter); + } } - printf("%d", number); + ++i; + } + int result = popElements(&buffer, errorCode); + if (*errorCode == 0) { + return 0; } + return result; } int main() { setlocale(LC_ALL, "RUS"); - char stringOfActions[100] = {'\0'}; + char stringOfActions[101] = {'\0'}; printf(" , 100 \n"); - int checkScanf = scanf("%s", &stringOfActions); - while (checkScanf != 1) - { - while (getchar() != '\n') { - } - printf("%s", "... - . \n"); - int checkScanf = scanf("%s", &stringOfActions); + gets_s(stringOfActions, 100); + int errorCode = 1; + int result = elementsForStack(stringOfActions, &errorCode); + if (errorCode == 0) { + printf("...\n"); + } else { + printf("%s %d\n", ":", result); } - elementsForStack(stringOfActions); - -} - -int scanOne() { - int number = 0; - int checkScanf = scanf("%d", &number); - printf("2 %c", checkScanf); - while (checkScanf != 1) { - while (getchar() != '\n') { - } - - printf("%s", "... \n"); - checkScanf = scanf("%d", &number); - } - - return number; } \ No newline at end of file diff --git a/postfixCalculator/postfixCalculator/stack.c b/postfixCalculator/postfixCalculator/stack.c index f7351b6..eb8be7f 100644 --- a/postfixCalculator/postfixCalculator/stack.c +++ b/postfixCalculator/postfixCalculator/stack.c @@ -28,13 +28,10 @@ void clear(ElementStack** head) { int popElements(ElementStack** head, int* errorCode) { if (*head == NULL) { if (errorCode != NULL) { - *errorCode = -1; + *errorCode = 0; } return -1; } - if (errorCode != NULL) { - *errorCode = 0; - } int value = (*head)->value; From 8fc9efc00eabcae797b445145293f5be4da4019d Mon Sep 17 00:00:00 2001 From: Artem Date: Tue, 18 Oct 2022 18:48:49 +0300 Subject: [PATCH 12/19] =?UTF-8?q?=D0=94=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D0=BB=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8E=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=D0=B5=D0=BC=D0=B0=20=D1=81=D1=82=D1=80=D0=BE=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B8=20=D0=BD=D0=B0=D1=88=D1=91=D0=BB=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BA=D0=B8,=20=D1=81=D0=B2=D1=8F=D0=B7=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D0=B5=20=D1=81=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B0=D1=87=D0=B5=D0=B9=20=D1=83=D0=BA=D0=B0=D0=B7=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postfixCalculator/postfixCalculator/main.c | 66 +++++++++++---------- postfixCalculator/postfixCalculator/stack.c | 3 +- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/postfixCalculator/postfixCalculator/main.c b/postfixCalculator/postfixCalculator/main.c index 9ae17a6..d48fa26 100644 --- a/postfixCalculator/postfixCalculator/main.c +++ b/postfixCalculator/postfixCalculator/main.c @@ -4,74 +4,75 @@ #include #include -int plus(ElementStack* buffer, int* errorCode) { - if (buffer == NULL) { +int plus(ElementStack** buffer, int* errorCode) { + if (*buffer == NULL) { *errorCode = 0; return 0; } - int firstNumber = popElements(&buffer, &errorCode); - if (errorCode == 0) { + int firstNumber = popElements(buffer, errorCode); + if (*errorCode == 0) { return 0; } - int secondNumber = popElements(&buffer, &errorCode); - if (errorCode == 0) { + int secondNumber = popElements(buffer, errorCode); + if (*errorCode == 0) { return 0; } return firstNumber + secondNumber; } -int minus(ElementStack* buffer, int* errorCode) { - if (buffer == NULL) { +int minus(ElementStack** buffer, int* errorCode) { + if (*buffer == NULL) { *errorCode = 0; return 0; } - int firstNumber = popElements(&buffer, &errorCode); - if (errorCode == 0) { + int firstNumber = popElements(buffer, errorCode); + if (*errorCode == 0) { return 0; } - int secondNumber = popElements(&buffer, &errorCode); - if (errorCode == 0) { + int secondNumber = popElements(buffer, errorCode); + if (*errorCode == 0) { return 0; } return secondNumber - firstNumber; } -int multiply(ElementStack* buffer, int* errorCode) { - if (buffer == NULL) { +int multiply(ElementStack** buffer, int* errorCode) { + if (*buffer == NULL) { *errorCode = 0; return 0; } - int firstNumber = popElements(&buffer, &errorCode); - if (errorCode == 0) { + int firstNumber = popElements(buffer, errorCode); + if (*errorCode == 0) { return 0; } - int secondNumber = popElements(&buffer, &errorCode); - if (errorCode == 0) { + int secondNumber = popElements(buffer, errorCode); + if (*errorCode == 0) { return 0; } return firstNumber * secondNumber; } -int divide(ElementStack* buffer, int* errorCode) { - if (buffer == NULL) { +int divide(ElementStack** buffer, int* errorCode) { + if (*buffer == NULL) { *errorCode = 0; return 0; } - int firstNumber = popElements(&buffer, &errorCode); - if (errorCode == 0) { + int firstNumber = popElements(buffer, errorCode); + if (*errorCode == 0) { return 0; } - int secondNumber = popElements(&buffer, &errorCode); - if (errorCode == 0) { + int secondNumber = popElements(buffer, errorCode); + if (*errorCode == 0) { return 0; } + return secondNumber / firstNumber; } int elementsForStack(char stringOfActions[], int* errorCode) { size_t sizeString = strlen(stringOfActions); size_t i = 0; - ElementStack* buffer; + ElementStack* buffer = NULL; while(i < sizeString) { int number = 0; int multiplier = 1; @@ -82,31 +83,32 @@ int elementsForStack(char stringOfActions[], int* errorCode) { multiplier = 10; ++i; } + --i; pushElements(&buffer, number); } else { if (stringOfActions[i] == '*') { - int numberAfter = multiply(buffer, errorCode); + int numberAfter = multiply(&buffer, errorCode); if (*errorCode == 0) { return 0; } pushElements(&buffer, numberAfter); } else if (stringOfActions[i] == '+') { - int numberAfter = plus(buffer, errorCode); + int numberAfter = plus(&buffer, errorCode); if (*errorCode == 0) { return 0; } pushElements(&buffer, numberAfter); } else if (stringOfActions[i] == '-') { - int numberAfter = minus(buffer, errorCode); + int numberAfter = minus(&buffer, errorCode); if (*errorCode == 0) { return 0; } pushElements(&buffer, numberAfter); } - else if (stringOfActions[i] == '\\') { - int numberAfter = divide(buffer, errorCode); + else if (stringOfActions[i] == '/') { + int numberAfter = divide(&buffer, errorCode); if (*errorCode == 0) { return 0; } @@ -119,6 +121,10 @@ int elementsForStack(char stringOfActions[], int* errorCode) { if (*errorCode == 0) { return 0; } + if (buffer != NULL) { + printf(" \n"); + return 0; + } return result; } diff --git a/postfixCalculator/postfixCalculator/stack.c b/postfixCalculator/postfixCalculator/stack.c index eb8be7f..a6765db 100644 --- a/postfixCalculator/postfixCalculator/stack.c +++ b/postfixCalculator/postfixCalculator/stack.c @@ -28,7 +28,7 @@ void clear(ElementStack** head) { int popElements(ElementStack** head, int* errorCode) { if (*head == NULL) { if (errorCode != NULL) { - *errorCode = 0; + *errorCode = 0; } return -1; } @@ -38,5 +38,6 @@ int popElements(ElementStack** head, int* errorCode) { ElementStack* temp = (*head)->next; free(*head); *head = temp; + return value; } \ No newline at end of file From 6c8752ff881ad56d36deabde55263b3b1ad957df Mon Sep 17 00:00:00 2001 From: Artem Date: Tue, 18 Oct 2022 20:22:26 +0300 Subject: [PATCH 13/19] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=B8=D0=B7=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=BB=20=D1=81=D1=82=D0=B0=D1=80=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BE=D0=B5=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20errorCode=20=D0=BD=D0=B0=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postfixCalculator/postfixCalculator/main.c | 50 ++++++++++++++------- postfixCalculator/postfixCalculator/stack.c | 2 +- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/postfixCalculator/postfixCalculator/main.c b/postfixCalculator/postfixCalculator/main.c index d48fa26..dc19883 100644 --- a/postfixCalculator/postfixCalculator/main.c +++ b/postfixCalculator/postfixCalculator/main.c @@ -10,11 +10,11 @@ int plus(ElementStack** buffer, int* errorCode) { return 0; } int firstNumber = popElements(buffer, errorCode); - if (*errorCode == 0) { + if (*errorCode == 1) { return 0; } int secondNumber = popElements(buffer, errorCode); - if (*errorCode == 0) { + if (*errorCode == 1) { return 0; } return firstNumber + secondNumber; @@ -26,11 +26,11 @@ int minus(ElementStack** buffer, int* errorCode) { return 0; } int firstNumber = popElements(buffer, errorCode); - if (*errorCode == 0) { + if (*errorCode == 1) { return 0; } int secondNumber = popElements(buffer, errorCode); - if (*errorCode == 0) { + if (*errorCode == 1) { return 0; } return secondNumber - firstNumber; @@ -42,11 +42,11 @@ int multiply(ElementStack** buffer, int* errorCode) { return 0; } int firstNumber = popElements(buffer, errorCode); - if (*errorCode == 0) { + if (*errorCode == 1) { return 0; } int secondNumber = popElements(buffer, errorCode); - if (*errorCode == 0) { + if (*errorCode == 1) { return 0; } return firstNumber * secondNumber; @@ -54,15 +54,15 @@ int multiply(ElementStack** buffer, int* errorCode) { int divide(ElementStack** buffer, int* errorCode) { if (*buffer == NULL) { - *errorCode = 0; + *errorCode = 1; return 0; } int firstNumber = popElements(buffer, errorCode); - if (*errorCode == 0) { + if (*errorCode == 1) { return 0; } int secondNumber = popElements(buffer, errorCode); - if (*errorCode == 0) { + if (*errorCode == 1) { return 0; } @@ -88,28 +88,28 @@ int elementsForStack(char stringOfActions[], int* errorCode) { } else { if (stringOfActions[i] == '*') { int numberAfter = multiply(&buffer, errorCode); - if (*errorCode == 0) { + if (*errorCode == 1) { return 0; } pushElements(&buffer, numberAfter); } else if (stringOfActions[i] == '+') { int numberAfter = plus(&buffer, errorCode); - if (*errorCode == 0) { + if (*errorCode == 1) { return 0; } pushElements(&buffer, numberAfter); } else if (stringOfActions[i] == '-') { int numberAfter = minus(&buffer, errorCode); - if (*errorCode == 0) { + if (*errorCode == 1) { return 0; } pushElements(&buffer, numberAfter); } else if (stringOfActions[i] == '/') { int numberAfter = divide(&buffer, errorCode); - if (*errorCode == 0) { + if (*errorCode == 1) { return 0; } pushElements(&buffer, numberAfter); @@ -118,7 +118,7 @@ int elementsForStack(char stringOfActions[], int* errorCode) { ++i; } int result = popElements(&buffer, errorCode); - if (*errorCode == 0) { + if (*errorCode == 1) { return 0; } if (buffer != NULL) { @@ -128,14 +128,32 @@ int elementsForStack(char stringOfActions[], int* errorCode) { return result; } +bool firstTest(void) { + char testString[6] = { '1',' ', '2', ' ', '+', '\0' }; + int errorCode = 0; + return elementsForStack(testString, &errorCode) == 3 && errorCode == 0 ? true : false; +} + +bool seconfTest(void) { + char testString[14] = { '1',' ', '2', ' ', '+', ' ', '4', ' ', '3', ' ', '*', ' ', '*', '\0' }; + int errorCode = 0; + return elementsForStack(testString, &errorCode) == 36 && errorCode == 0 ? true : false; +} + int main() { setlocale(LC_ALL, "RUS"); + if (!firstTest() || !seconfTest()) { + printf("- ...\n"); + return 0; + } else { + printf(" !\n"); + } char stringOfActions[101] = {'\0'}; printf(" , 100 \n"); gets_s(stringOfActions, 100); - int errorCode = 1; + int errorCode = 0; int result = elementsForStack(stringOfActions, &errorCode); - if (errorCode == 0) { + if (errorCode == 1) { printf("...\n"); } else { printf("%s %d\n", ":", result); diff --git a/postfixCalculator/postfixCalculator/stack.c b/postfixCalculator/postfixCalculator/stack.c index a6765db..025ef85 100644 --- a/postfixCalculator/postfixCalculator/stack.c +++ b/postfixCalculator/postfixCalculator/stack.c @@ -28,7 +28,7 @@ void clear(ElementStack** head) { int popElements(ElementStack** head, int* errorCode) { if (*head == NULL) { if (errorCode != NULL) { - *errorCode = 0; + *errorCode = 1; } return -1; } From 761ba1e13f60e804b9c5a527cc793bc7a11ca01b Mon Sep 17 00:00:00 2001 From: Palezehvat <114094069+Palezehvat@users.noreply.github.com> Date: Tue, 18 Oct 2022 20:30:39 +0300 Subject: [PATCH 14/19] 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 0d01f7f44b5450e518cd8c75e6c86aad6fa26410 Mon Sep 17 00:00:00 2001 From: Artem Date: Tue, 18 Oct 2022 20:51:14 +0300 Subject: [PATCH 15/19] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=81=D1=82=D0=B5=D0=BA,=20=D0=BD=D0=B0=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=B0=D0=BB=20=D1=82=D0=B5=D1=81=D1=82=D1=8B,=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BF=D1=80=D0=BE=D0=B1=D1=83=D1=8E=20=D0=B2=20=D1=8D?= =?UTF-8?q?=D1=82=D0=BE=D1=82=20=D1=80=D0=B0=D0=B7=20=D0=BD=D0=B0=D1=87?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D1=81=20=D1=82=D0=B5=D1=81=D1=82=D0=BE?= =?UTF-8?q?=D0=B2,=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=B1=D1=8B=D1=81=D1=82=D1=80=D0=B5=D0=B5=20=D1=82?= =?UTF-8?q?=D0=B0=D0=BA=20=D1=80=D0=B5=D1=88=D0=B0=D0=B5=D1=82=D1=81=D1=8F?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B0=20=D0=B8=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=BD=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- balancedStaples/balancedStaples.sln | 31 ++++ .../balancedStaples/balancedStaples.vcxproj | 150 ++++++++++++++++++ .../balancedStaples.vcxproj.filters | 17 ++ balancedStaples/balancedStaples/main.c | 22 +++ balancedStaples/balancedStaples/stack.c | 43 +++++ balancedStaples/balancedStaples/stack.h | 16 ++ 6 files changed, 279 insertions(+) create mode 100644 balancedStaples/balancedStaples.sln create mode 100644 balancedStaples/balancedStaples/balancedStaples.vcxproj create mode 100644 balancedStaples/balancedStaples/balancedStaples.vcxproj.filters create mode 100644 balancedStaples/balancedStaples/main.c create mode 100644 balancedStaples/balancedStaples/stack.c create mode 100644 balancedStaples/balancedStaples/stack.h diff --git a/balancedStaples/balancedStaples.sln b/balancedStaples/balancedStaples.sln new file mode 100644 index 0000000..5177753 --- /dev/null +++ b/balancedStaples/balancedStaples.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}") = "balancedStaples", "balancedStaples\balancedStaples.vcxproj", "{46537355-D9A5-46D5-B708-16078F3BA9C3}" +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 + {46537355-D9A5-46D5-B708-16078F3BA9C3}.Debug|x64.ActiveCfg = Debug|x64 + {46537355-D9A5-46D5-B708-16078F3BA9C3}.Debug|x64.Build.0 = Debug|x64 + {46537355-D9A5-46D5-B708-16078F3BA9C3}.Debug|x86.ActiveCfg = Debug|Win32 + {46537355-D9A5-46D5-B708-16078F3BA9C3}.Debug|x86.Build.0 = Debug|Win32 + {46537355-D9A5-46D5-B708-16078F3BA9C3}.Release|x64.ActiveCfg = Release|x64 + {46537355-D9A5-46D5-B708-16078F3BA9C3}.Release|x64.Build.0 = Release|x64 + {46537355-D9A5-46D5-B708-16078F3BA9C3}.Release|x86.ActiveCfg = Release|Win32 + {46537355-D9A5-46D5-B708-16078F3BA9C3}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3F667BC7-35D6-494F-A946-075F5C44FD74} + EndGlobalSection +EndGlobal diff --git a/balancedStaples/balancedStaples/balancedStaples.vcxproj b/balancedStaples/balancedStaples/balancedStaples.vcxproj new file mode 100644 index 0000000..0c53cc9 --- /dev/null +++ b/balancedStaples/balancedStaples/balancedStaples.vcxproj @@ -0,0 +1,150 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + 16.0 + Win32Proj + {46537355-d9a5-46d5-b708-16078f3ba9c3} + balancedStaples + 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/balancedStaples/balancedStaples/balancedStaples.vcxproj.filters b/balancedStaples/balancedStaples/balancedStaples.vcxproj.filters new file mode 100644 index 0000000..153170c --- /dev/null +++ b/balancedStaples/balancedStaples/balancedStaples.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 diff --git a/balancedStaples/balancedStaples/main.c b/balancedStaples/balancedStaples/main.c new file mode 100644 index 0000000..996ea9e --- /dev/null +++ b/balancedStaples/balancedStaples/main.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +bool isBalanced(char stringStaples[]) { + +} + +bool firstTest(void) { + char stringStaples[5] = { '{', '}', '(', ')', '\0'}; + return isBalanced(stringStaples) == false; +} + +bool secondTest(void) { + char stringStaples[5] = { '{', '(', ')', '}', '\0'}; + return isBalanced(stringStaples) == true; +} + +int main() { + +} \ No newline at end of file diff --git a/balancedStaples/balancedStaples/stack.c b/balancedStaples/balancedStaples/stack.c new file mode 100644 index 0000000..e127b3f --- /dev/null +++ b/balancedStaples/balancedStaples/stack.c @@ -0,0 +1,43 @@ +#include "stack.h" +#include +#include +#include + +int pushElements(ElementStack** head, int value) { + ElementStack* temp = malloc(sizeof(ElementStack)); + if (temp == NULL) { + return -1; + } + temp->value = value; + temp->next = *head; + + *head = temp; + return 0; +} + +bool isEmpty(ElementStack* head) { + return head == NULL; +} + +void clear(ElementStack** head) { + while (!isEmpty(*head)) { + popElements(head, NULL); + } +} + +int popElements(ElementStack** head, int* errorCode) { + if (*head == NULL) { + if (errorCode != NULL) { + *errorCode = 1; + } + return -1; + } + + int value = (*head)->value; + + ElementStack* temp = (*head)->next; + free(*head); + *head = temp; + + return value; +} \ No newline at end of file diff --git a/balancedStaples/balancedStaples/stack.h b/balancedStaples/balancedStaples/stack.h new file mode 100644 index 0000000..360cd6f --- /dev/null +++ b/balancedStaples/balancedStaples/stack.h @@ -0,0 +1,16 @@ +#ifndef STACK_H_ +#define STACK_H_ +#include + +typedef struct ElementStack { + struct ElementStack* next; + int value; +} ElementStack; + +int pushElements(ElementStack** head, int value); +bool isEmpty(ElementStack* head); +void clear(ElementStack** head); +int popElements(ElementStack** head, int* errorCode); + +#endif // !STACK_H_ + From f69f38fe94c56e9cead39ff7190a717b1f81e7ff Mon Sep 17 00:00:00 2001 From: Palezehvat <114094069+Palezehvat@users.noreply.github.com> Date: Tue, 18 Oct 2022 20:55:36 +0300 Subject: [PATCH 16/19] Delete postfixCalculator directory --- postfixCalculator/postfixCalculator.sln | 31 ---- postfixCalculator/postfixCalculator/main.c | 161 ------------------ .../postfixCalculator.vcxproj | 151 ---------------- .../postfixCalculator.vcxproj.filters | 30 ---- postfixCalculator/postfixCalculator/stack.c | 43 ----- postfixCalculator/postfixCalculator/stack.h | 16 -- 6 files changed, 432 deletions(-) delete mode 100644 postfixCalculator/postfixCalculator.sln delete mode 100644 postfixCalculator/postfixCalculator/main.c delete mode 100644 postfixCalculator/postfixCalculator/postfixCalculator.vcxproj delete mode 100644 postfixCalculator/postfixCalculator/postfixCalculator.vcxproj.filters delete mode 100644 postfixCalculator/postfixCalculator/stack.c delete mode 100644 postfixCalculator/postfixCalculator/stack.h diff --git a/postfixCalculator/postfixCalculator.sln b/postfixCalculator/postfixCalculator.sln deleted file mode 100644 index 0b3ac41..0000000 --- a/postfixCalculator/postfixCalculator.sln +++ /dev/null @@ -1,31 +0,0 @@ - -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}") = "postfixCalculator", "postfixCalculator\postfixCalculator.vcxproj", "{8C7F0589-31A5-4678-A9C7-6C64BC73BE70}" -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 - {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Debug|x64.ActiveCfg = Debug|x64 - {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Debug|x64.Build.0 = Debug|x64 - {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Debug|x86.ActiveCfg = Debug|Win32 - {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Debug|x86.Build.0 = Debug|Win32 - {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Release|x64.ActiveCfg = Release|x64 - {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Release|x64.Build.0 = Release|x64 - {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Release|x86.ActiveCfg = Release|Win32 - {8C7F0589-31A5-4678-A9C7-6C64BC73BE70}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {0E76BB72-D754-45D2-AB98-9D4A536995AF} - EndGlobalSection -EndGlobal diff --git a/postfixCalculator/postfixCalculator/main.c b/postfixCalculator/postfixCalculator/main.c deleted file mode 100644 index dc19883..0000000 --- a/postfixCalculator/postfixCalculator/main.c +++ /dev/null @@ -1,161 +0,0 @@ -#include -#include "stack.h" -#include -#include -#include - -int plus(ElementStack** buffer, int* errorCode) { - if (*buffer == NULL) { - *errorCode = 0; - return 0; - } - int firstNumber = popElements(buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - int secondNumber = popElements(buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - return firstNumber + secondNumber; -} - -int minus(ElementStack** buffer, int* errorCode) { - if (*buffer == NULL) { - *errorCode = 0; - return 0; - } - int firstNumber = popElements(buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - int secondNumber = popElements(buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - return secondNumber - firstNumber; -} - -int multiply(ElementStack** buffer, int* errorCode) { - if (*buffer == NULL) { - *errorCode = 0; - return 0; - } - int firstNumber = popElements(buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - int secondNumber = popElements(buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - return firstNumber * secondNumber; -} - -int divide(ElementStack** buffer, int* errorCode) { - if (*buffer == NULL) { - *errorCode = 1; - return 0; - } - int firstNumber = popElements(buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - int secondNumber = popElements(buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - - return secondNumber / firstNumber; -} - -int elementsForStack(char stringOfActions[], int* errorCode) { - size_t sizeString = strlen(stringOfActions); - size_t i = 0; - ElementStack* buffer = NULL; - while(i < sizeString) { - int number = 0; - int multiplier = 1; - if (stringOfActions[i] >= '0' && stringOfActions[i] <= '9') { - while (stringOfActions[i] >= '0' && stringOfActions[i] <= '9') { - number *= multiplier; - number += ((int)stringOfActions[i] - 48); - multiplier = 10; - ++i; - } - --i; - pushElements(&buffer, number); - } else { - if (stringOfActions[i] == '*') { - int numberAfter = multiply(&buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - pushElements(&buffer, numberAfter); - } - else if (stringOfActions[i] == '+') { - int numberAfter = plus(&buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - pushElements(&buffer, numberAfter); - } - else if (stringOfActions[i] == '-') { - int numberAfter = minus(&buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - pushElements(&buffer, numberAfter); - } - else if (stringOfActions[i] == '/') { - int numberAfter = divide(&buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - pushElements(&buffer, numberAfter); - } - } - ++i; - } - int result = popElements(&buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - if (buffer != NULL) { - printf(" \n"); - return 0; - } - return result; -} - -bool firstTest(void) { - char testString[6] = { '1',' ', '2', ' ', '+', '\0' }; - int errorCode = 0; - return elementsForStack(testString, &errorCode) == 3 && errorCode == 0 ? true : false; -} - -bool seconfTest(void) { - char testString[14] = { '1',' ', '2', ' ', '+', ' ', '4', ' ', '3', ' ', '*', ' ', '*', '\0' }; - int errorCode = 0; - return elementsForStack(testString, &errorCode) == 36 && errorCode == 0 ? true : false; -} - -int main() { - setlocale(LC_ALL, "RUS"); - if (!firstTest() || !seconfTest()) { - printf("- ...\n"); - return 0; - } else { - printf(" !\n"); - } - char stringOfActions[101] = {'\0'}; - printf(" , 100 \n"); - gets_s(stringOfActions, 100); - int errorCode = 0; - int result = elementsForStack(stringOfActions, &errorCode); - if (errorCode == 1) { - printf("...\n"); - } else { - printf("%s %d\n", ":", result); - } -} \ No newline at end of file diff --git a/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj b/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj deleted file mode 100644 index 8d1e185..0000000 --- a/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj +++ /dev/null @@ -1,151 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {8c7f0589-31a5-4678-a9c7-6c64bc73be70} - postfixCalculator - 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 - false - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - \ No newline at end of file diff --git a/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj.filters b/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj.filters deleted file mode 100644 index 6498e61..0000000 --- a/postfixCalculator/postfixCalculator/postfixCalculator.vcxproj.filters +++ /dev/null @@ -1,30 +0,0 @@ - - - - - {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 diff --git a/postfixCalculator/postfixCalculator/stack.c b/postfixCalculator/postfixCalculator/stack.c deleted file mode 100644 index 025ef85..0000000 --- a/postfixCalculator/postfixCalculator/stack.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "stack.h" -#include -#include -#include - -int pushElements(ElementStack** head, int value) { - ElementStack* temp = malloc(sizeof(ElementStack)); - if (temp == NULL) { - return -1; - } - temp->value = value; - temp->next = *head; - - *head = temp; - return 0; -} - -bool isEmpty(ElementStack* head) { - return head == NULL; -} - -void clear(ElementStack** head) { - while (!isEmpty(*head)) { - popElements(head, NULL); - } -} - -int popElements(ElementStack** head, int* errorCode) { - if (*head == NULL) { - if (errorCode != NULL) { - *errorCode = 1; - } - return -1; - } - - int value = (*head)->value; - - ElementStack* temp = (*head)->next; - free(*head); - *head = temp; - - return value; -} \ No newline at end of file diff --git a/postfixCalculator/postfixCalculator/stack.h b/postfixCalculator/postfixCalculator/stack.h deleted file mode 100644 index 360cd6f..0000000 --- a/postfixCalculator/postfixCalculator/stack.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef STACK_H_ -#define STACK_H_ -#include - -typedef struct ElementStack { - struct ElementStack* next; - int value; -} ElementStack; - -int pushElements(ElementStack** head, int value); -bool isEmpty(ElementStack* head); -void clear(ElementStack** head); -int popElements(ElementStack** head, int* errorCode); - -#endif // !STACK_H_ - From 1aff27710d9e43866013ac715cb2d9039443a766 Mon Sep 17 00:00:00 2001 From: Artem Date: Tue, 18 Oct 2022 22:14:51 +0300 Subject: [PATCH 17/19] =?UTF-8?q?=D0=94=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D0=BB=20=D1=81=D0=BA=D0=BE=D0=B1=D0=BA=D0=B8,=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D0=BD=D0=B5=D0=BC?= =?UTF-8?q?=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=81=D1=82=D0=B5=D0=BA=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=20char,=20=D1=87=D1=82=D0=BE=D0=B1=D1=8B=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D1=8F=D1=82=D1=8C?= =?UTF-8?q?=20int=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D0=BE=20ascii?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../balancedStaples/balancedStaples.vcxproj | 43 ++++++++--------- .../balancedStaples.vcxproj.filters | 13 +++++ balancedStaples/balancedStaples/main.c | 47 ++++++++++++++++--- balancedStaples/balancedStaples/stack.c | 4 +- balancedStaples/balancedStaples/stack.h | 6 +-- 5 files changed, 81 insertions(+), 32 deletions(-) diff --git a/balancedStaples/balancedStaples/balancedStaples.vcxproj b/balancedStaples/balancedStaples/balancedStaples.vcxproj index 0c53cc9..8c89231 100644 --- a/balancedStaples/balancedStaples/balancedStaples.vcxproj +++ b/balancedStaples/balancedStaples/balancedStaples.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/balancedStaples/balancedStaples/balancedStaples.vcxproj.filters b/balancedStaples/balancedStaples/balancedStaples.vcxproj.filters index 153170c..6498e61 100644 --- a/balancedStaples/balancedStaples/balancedStaples.vcxproj.filters +++ b/balancedStaples/balancedStaples/balancedStaples.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 diff --git a/balancedStaples/balancedStaples/main.c b/balancedStaples/balancedStaples/main.c index 996ea9e..825884a 100644 --- a/balancedStaples/balancedStaples/main.c +++ b/balancedStaples/balancedStaples/main.c @@ -2,21 +2,56 @@ #include #include #include +#include "stack.h" +#include -bool isBalanced(char stringStaples[]) { - +bool isBalanced(char stringStaples[], int* errorCode) { + ElementStack* buffer = NULL; + size_t sizeStringStaples = strlen(stringStaples); + size_t i = 0; + while(i < sizeStringStaples) { + if (stringStaples[i] == '{' || stringStaples[i] == '(' || stringStaples[i] == '[') { + pushElements(&buffer, stringStaples[i]); + } else if (stringStaples[i] == ']' || stringStaples[i] == ')' || stringStaples[i] == '}') { + char lastOpenStaple = popElements(&buffer, errorCode); + if (*errorCode == 1 || !((lastOpenStaple == '[' && stringStaples[i] == ']') || (lastOpenStaple == '(' && stringStaples[i] == ')') || (lastOpenStaple == '{' && stringStaples[i] == '}') )) { + return false; + } + } else { + *errorCode = 1; + return false; + } + ++i; + } + if (buffer != NULL) { + return false; + } + return true; } bool firstTest(void) { - char stringStaples[5] = { '{', '}', '(', ')', '\0'}; - return isBalanced(stringStaples) == false; + char stringStaples[5] = { '{', '(', '}', ')', '\0'}; + int errorCode = 0; + return isBalanced(stringStaples, &errorCode) == false && errorCode == 0; } bool secondTest(void) { char stringStaples[5] = { '{', '(', ')', '}', '\0'}; - return isBalanced(stringStaples) == true; + int errorCode = 0; + return isBalanced(stringStaples, &errorCode) == true && errorCode == 0; } int main() { - + setlocale(LC_ALL, "RUS"); + if (!firstTest() || !secondTest()) { + printf("...\n"); + return 0; + } else { + printf(" !\n"); + } + printf(" ( 100 )\n"); + char stringStaples[100]; + gets_s(stringStaples, 100); + int errorCode = 0; + printf(isBalanced(stringStaples, &errorCode) && errorCode == 0 ? " \n" : errorCode != 0 ? "..." : " \n"); } \ No newline at end of file diff --git a/balancedStaples/balancedStaples/stack.c b/balancedStaples/balancedStaples/stack.c index e127b3f..b5c843f 100644 --- a/balancedStaples/balancedStaples/stack.c +++ b/balancedStaples/balancedStaples/stack.c @@ -3,7 +3,7 @@ #include #include -int pushElements(ElementStack** head, int value) { +int pushElements(ElementStack** head, char value) { ElementStack* temp = malloc(sizeof(ElementStack)); if (temp == NULL) { return -1; @@ -25,7 +25,7 @@ void clear(ElementStack** head) { } } -int popElements(ElementStack** head, int* errorCode) { +char popElements(ElementStack** head, int* errorCode) { if (*head == NULL) { if (errorCode != NULL) { *errorCode = 1; diff --git a/balancedStaples/balancedStaples/stack.h b/balancedStaples/balancedStaples/stack.h index 360cd6f..d0a29f8 100644 --- a/balancedStaples/balancedStaples/stack.h +++ b/balancedStaples/balancedStaples/stack.h @@ -4,13 +4,13 @@ typedef struct ElementStack { struct ElementStack* next; - int value; + char value; } ElementStack; -int pushElements(ElementStack** head, int value); +int pushElements(ElementStack** head, char value); bool isEmpty(ElementStack* head); void clear(ElementStack** head); -int popElements(ElementStack** head, int* errorCode); +char popElements(ElementStack** head, int* errorCode); #endif // !STACK_H_ From dbd5106609afbde0e5e3b82f75bee81d3d1a93b3 Mon Sep 17 00:00:00 2001 From: Artem Date: Fri, 23 Dec 2022 11:33:57 +0300 Subject: [PATCH 18/19] =?UTF-8?q?=D0=A0=D0=B5=D0=B2=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- balancedStaples/balancedStaples/main.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/balancedStaples/balancedStaples/main.c b/balancedStaples/balancedStaples/main.c index 825884a..aa73f84 100644 --- a/balancedStaples/balancedStaples/main.c +++ b/balancedStaples/balancedStaples/main.c @@ -14,38 +14,44 @@ bool isBalanced(char stringStaples[], int* errorCode) { pushElements(&buffer, stringStaples[i]); } else if (stringStaples[i] == ']' || stringStaples[i] == ')' || stringStaples[i] == '}') { char lastOpenStaple = popElements(&buffer, errorCode); - if (*errorCode == 1 || !((lastOpenStaple == '[' && stringStaples[i] == ']') || (lastOpenStaple == '(' && stringStaples[i] == ')') || (lastOpenStaple == '{' && stringStaples[i] == '}') )) { + if (*errorCode == 1 + || !((lastOpenStaple == '[' && stringStaples[i] == ']') + || (lastOpenStaple == '(' && stringStaples[i] == ')') + || (lastOpenStaple == '{' && stringStaples[i] == '}') )) { + clear(&buffer); return false; } } else { *errorCode = 1; + clear(&buffer); return false; } ++i; } if (buffer != NULL) { + clear(&buffer); return false; } return true; } bool firstTest(void) { - char stringStaples[5] = { '{', '(', '}', ')', '\0'}; + char stringStaples[] = "{(})"; int errorCode = 0; - return isBalanced(stringStaples, &errorCode) == false && errorCode == 0; + return !isBalanced(stringStaples, &errorCode) && errorCode == 0; } bool secondTest(void) { - char stringStaples[5] = { '{', '(', ')', '}', '\0'}; + char stringStaples[] = "{()}"; int errorCode = 0; - return isBalanced(stringStaples, &errorCode) == true && errorCode == 0; + return isBalanced(stringStaples, &errorCode) && errorCode == 0; } int main() { setlocale(LC_ALL, "RUS"); if (!firstTest() || !secondTest()) { printf("...\n"); - return 0; + return -1; } else { printf(" !\n"); } @@ -53,5 +59,7 @@ int main() { char stringStaples[100]; gets_s(stringStaples, 100); int errorCode = 0; - printf(isBalanced(stringStaples, &errorCode) && errorCode == 0 ? " \n" : errorCode != 0 ? "..." : " \n"); + printf(isBalanced(stringStaples, &errorCode) && errorCode == 0 + ? " \n" + : errorCode != 0 ? "..." : " \n"); } \ No newline at end of file From dc318d4ec272508eb98d6719e78e9ef5a7e6c551 Mon Sep 17 00:00:00 2001 From: Artem Date: Fri, 23 Dec 2022 13:58:25 +0300 Subject: [PATCH 19/19] =?UTF-8?q?=D0=A0=D0=B5=D0=B2=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- balancedStaples/balancedStaples/stack.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/balancedStaples/balancedStaples/stack.h b/balancedStaples/balancedStaples/stack.h index d0a29f8..753d9d1 100644 --- a/balancedStaples/balancedStaples/stack.h +++ b/balancedStaples/balancedStaples/stack.h @@ -7,9 +7,16 @@ typedef struct ElementStack { char value; } ElementStack; +// . 0 , -1 . int pushElements(ElementStack** head, char value); + +// . bool isEmpty(ElementStack* head); + +// . void clear(ElementStack** head); + +// . , char popElements(ElementStack** head, int* errorCode); #endif // !STACK_H_