From 67bfd7d2d59c00b04daa0644df2a889e599c5310 Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 17 Oct 2022 15:16:11 +0300 Subject: [PATCH 01/14] =?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/14] =?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/14] 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/14] 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/14] 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/14] 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/14] =?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/14] =?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/14] =?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/14] =?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/14] =?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/14] =?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/14] =?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 8db96d8a51a207a8bba6c3c814f17742346184c6 Mon Sep 17 00:00:00 2001 From: Artem Date: Fri, 9 Dec 2022 20:06:08 +0300 Subject: [PATCH 14/14] =?UTF-8?q?=D0=9E=D0=BF=D1=82=D0=B8=D0=BC=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=86=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postfixCalculator/postfixCalculator/main.c | 150 ++++++-------------- postfixCalculator/postfixCalculator/stack.h | 1 + 2 files changed, 47 insertions(+), 104 deletions(-) diff --git a/postfixCalculator/postfixCalculator/main.c b/postfixCalculator/postfixCalculator/main.c index dc19883..58931dd 100644 --- a/postfixCalculator/postfixCalculator/main.c +++ b/postfixCalculator/postfixCalculator/main.c @@ -4,147 +4,89 @@ #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) { +int calculate(const 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; + while (i < sizeString) { if (stringOfActions[i] >= '0' && stringOfActions[i] <= '9') { + int multiplier = 10; + int number = 0; while (stringOfActions[i] >= '0' && stringOfActions[i] <= '9') { + number += stringOfActions[i] - '0'; number *= multiplier; - number += ((int)stringOfActions[i] - 48); - multiplier = 10; ++i; } + number /= 10; --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 = 0; + + int firstNumber = popElements(&buffer, errorCode); + if (*errorCode == 1) { + return 0; } - else if (stringOfActions[i] == '+') { - int numberAfter = plus(&buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - pushElements(&buffer, numberAfter); + int secondNumber = popElements(&buffer, errorCode); + if (*errorCode == 1) { + return 0; } - else if (stringOfActions[i] == '-') { - int numberAfter = minus(&buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - pushElements(&buffer, numberAfter); + + switch (stringOfActions[i]) { + case '*': + numberAfter = firstNumber * secondNumber; + break; + case '+': + numberAfter = firstNumber + secondNumber; + break; + case '-': + numberAfter = secondNumber - firstNumber; + break; + case '/': + numberAfter = secondNumber / firstNumber; + break; } - else if (stringOfActions[i] == '/') { - int numberAfter = divide(&buffer, errorCode); - if (*errorCode == 1) { - return 0; - } - pushElements(&buffer, numberAfter); + + if (*errorCode == 1) { + clear(&buffer); + 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' }; + const char *testString = "1 2 +"; int errorCode = 0; - return elementsForStack(testString, &errorCode) == 3 && errorCode == 0 ? true : false; + return calculate(testString, &errorCode) == 3 && errorCode == 0; } -bool seconfTest(void) { - char testString[14] = { '1',' ', '2', ' ', '+', ' ', '4', ' ', '3', ' ', '*', ' ', '*', '\0' }; +bool secondTest(void) { + const char *testString = "1 2 + 4 3 * *"; int errorCode = 0; - return elementsForStack(testString, &errorCode) == 36 && errorCode == 0 ? true : false; + return calculate(testString, &errorCode) == 36 && errorCode == 0; } int main() { setlocale(LC_ALL, "RUS"); - if (!firstTest() || !seconfTest()) { + if (!firstTest() || !secondTest()) { printf("- ...\n"); - return 0; + return -1; } else { printf(" !\n"); } @@ -152,7 +94,7 @@ int main() { printf(" , 100 \n"); gets_s(stringOfActions, 100); int errorCode = 0; - int result = elementsForStack(stringOfActions, &errorCode); + int result = calculate(stringOfActions, &errorCode); if (errorCode == 1) { printf("...\n"); } else { diff --git a/postfixCalculator/postfixCalculator/stack.h b/postfixCalculator/postfixCalculator/stack.h index 360cd6f..ca5369f 100644 --- a/postfixCalculator/postfixCalculator/stack.h +++ b/postfixCalculator/postfixCalculator/stack.h @@ -1,5 +1,6 @@ #ifndef STACK_H_ #define STACK_H_ + #include typedef struct ElementStack {