From 23b03fd98d1f3117bf6528b191fec762110e5b0f Mon Sep 17 00:00:00 2001 From: Victoria Date: Sat, 27 Oct 2018 18:02:56 +0300 Subject: [PATCH 01/17] project created --- .../from infix to postfix.sln | 31 +++++ .../from infix to postfix.vcxproj | 122 ++++++++++++++++++ .../from infix to postfix.vcxproj.filters | 17 +++ 3 files changed, 170 insertions(+) create mode 100644 hw6/from infix to postfix/from infix to postfix.sln create mode 100644 hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj create mode 100644 hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters diff --git a/hw6/from infix to postfix/from infix to postfix.sln b/hw6/from infix to postfix/from infix to postfix.sln new file mode 100644 index 0000000..15c917f --- /dev/null +++ b/hw6/from infix to postfix/from infix to postfix.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "from infix to postfix", "from infix to postfix\from infix to postfix.vcxproj", "{54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}" +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 + {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Debug|x64.ActiveCfg = Debug|x64 + {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Debug|x64.Build.0 = Debug|x64 + {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Debug|x86.ActiveCfg = Debug|Win32 + {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Debug|x86.Build.0 = Debug|Win32 + {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Release|x64.ActiveCfg = Release|x64 + {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Release|x64.Build.0 = Release|x64 + {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Release|x86.ActiveCfg = Release|Win32 + {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {05DC8ABC-44E6-489E-859E-8BB93557CE7C} + EndGlobalSection +EndGlobal diff --git a/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj b/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj new file mode 100644 index 0000000..b8ada17 --- /dev/null +++ b/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj @@ -0,0 +1,122 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD} + frominfixtopostfix + 10.0.17134.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + true + + + + + Level3 + Disabled + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + + + + + + \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters b/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters new file mode 100644 index 0000000..7e58074 --- /dev/null +++ b/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters @@ -0,0 +1,17 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;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 18244c75ceba89784bce022d236350da10d9ef5d Mon Sep 17 00:00:00 2001 From: Victoria Date: Sun, 28 Oct 2018 00:04:17 +0300 Subject: [PATCH 02/17] almost finished --- .../from infix to postfix/Element.cpp | 13 ++++ .../from infix to postfix/Element.h | 9 +++ .../Infix to postfix.cpp | 64 ++++++++++++++++++ .../from infix to postfix/Infix to postfix.h | 8 +++ .../from infix to postfix/Stack.cpp | 65 +++++++++++++++++++ .../from infix to postfix/Stack.h | 28 ++++++++ .../from infix to postfix.vcxproj | 9 +++ .../from infix to postfix.vcxproj.filters | 25 +++++++ .../from infix to postfix/main.cpp | 17 +++++ 9 files changed, 238 insertions(+) create mode 100644 hw6/from infix to postfix/from infix to postfix/Element.cpp create mode 100644 hw6/from infix to postfix/from infix to postfix/Element.h create mode 100644 hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp create mode 100644 hw6/from infix to postfix/from infix to postfix/Infix to postfix.h create mode 100644 hw6/from infix to postfix/from infix to postfix/Stack.cpp create mode 100644 hw6/from infix to postfix/from infix to postfix/Stack.h create mode 100644 hw6/from infix to postfix/from infix to postfix/main.cpp diff --git a/hw6/from infix to postfix/from infix to postfix/Element.cpp b/hw6/from infix to postfix/from infix to postfix/Element.cpp new file mode 100644 index 0000000..8bbeb35 --- /dev/null +++ b/hw6/from infix to postfix/from infix to postfix/Element.cpp @@ -0,0 +1,13 @@ +#include "Element.h" + +Element::Element(char data = '\0') +{ + this->data = data; + this->next = nullptr; +} + +Element::~Element() +{ + this->data = '\0'; + this->next = nullptr; +} \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/Element.h b/hw6/from infix to postfix/from infix to postfix/Element.h new file mode 100644 index 0000000..f15288d --- /dev/null +++ b/hw6/from infix to postfix/from infix to postfix/Element.h @@ -0,0 +1,9 @@ +#pragma once + +struct Element +{ + Element(char data); + ~Element(); + char data; + Element* next; +}; \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp new file mode 100644 index 0000000..c4c868b --- /dev/null +++ b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp @@ -0,0 +1,64 @@ +#include "Infix to postfix.h" + +bool isOperator(char const symbol); +bool ifOperatorHasHigherPriority(char const operatorCheck, char const operatorCompareWith); + +void infixToPostfix(string & infix, string & toPostfix) +{ + Stack s; + int count = 0; + for (int i = 0; i < (int)infix.size(); ++i) + { + if (!isOperator(infix[i])) + { + toPostfix[count] = infix[i]; + ++count; + } + else + { + while (!s.isEmpty()) + { + if (ifOperatorHasHigherPriority(infix[i], s.peek())) + { + break; + } + else + { + toPostfix[count] = s.peek(); + s.pop(); + ++count; + } + } + s.push(infix[i]); + } + } + while (!s.isEmpty()) + { + toPostfix[count] = s.peek(); + s.pop(); + } +} + +bool isOperator(char const symbol) +{ + return (symbol == '+' || symbol == '-' || symbol == '*' || symbol == '/'); +} + +bool ifOperatorHasHigherPriority(char const operatorCheck, char const operatorCompareWith) +{ + if (operatorCheck == '+' || operatorCheck == '-') + { + return false; + } + else + { + if (operatorCompareWith == '*' || operatorCompareWith == '/') + { + return false; + } + else + { + return true; + } + } +} \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h new file mode 100644 index 0000000..c142aa6 --- /dev/null +++ b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h @@ -0,0 +1,8 @@ +#pragma once +#include +#include +#include "Stack.h" + +using namespace std; + +void infixToPostfix(string & infix, string & toPostfix); \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/Stack.cpp b/hw6/from infix to postfix/from infix to postfix/Stack.cpp new file mode 100644 index 0000000..000c1f2 --- /dev/null +++ b/hw6/from infix to postfix/from infix to postfix/Stack.cpp @@ -0,0 +1,65 @@ +#include "Stack.h" +#include "Element.h" + +Stack::Stack() +{ + head = nullptr; +} + +Stack::~Stack() +{ + auto* temp = head; + while (!isEmpty()) + { + temp = head; + head = temp->next; + temp->next = nullptr; + delete temp; + temp = nullptr; + } +} + +void Stack::push(char data) +{ + auto* newElement = new Element(data); + if (!isEmpty()) + { + newElement->next = head; + } + head = newElement; +} + +int Stack::pop() +{ + if (!isEmpty()) + { + auto* temp = head->next; + head->next = nullptr; + delete head; + head = nullptr; + head = temp; + return 0; + } + else + { + return -1; + } +} + +char Stack::peek() +{ + if (!isEmpty()) + { + return head->data; + } + else + { + cout << "Stack is empty\n"; + return '\0'; + } +} + +bool Stack::isEmpty() +{ + return head == nullptr; +} \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/Stack.h b/hw6/from infix to postfix/from infix to postfix/Stack.h new file mode 100644 index 0000000..9a208c5 --- /dev/null +++ b/hw6/from infix to postfix/from infix to postfix/Stack.h @@ -0,0 +1,28 @@ +#pragma once +#include + +using namespace std; + +struct Element; + +struct Stack +{ + // + Stack(); + // + ~Stack(); + // + + // + + // + void push(char data); + // + int pop(); + // + char peek(); + // + bool isEmpty(); +private: + Element * head; +}; \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj b/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj index b8ada17..15c763d 100644 --- a/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj +++ b/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj @@ -115,6 +115,15 @@ + + + + + + + + + diff --git a/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters b/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters index 7e58074..25e11fb 100644 --- a/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters +++ b/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters @@ -14,4 +14,29 @@ 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/hw6/from infix to postfix/from infix to postfix/main.cpp b/hw6/from infix to postfix/from infix to postfix/main.cpp new file mode 100644 index 0000000..5f54c9b --- /dev/null +++ b/hw6/from infix to postfix/from infix to postfix/main.cpp @@ -0,0 +1,17 @@ +#include +#include "Infix to postfix.h" + +using namespace std; + +int main() +{ + string infix; + cout << "Input infix expression\n"; + cin >> infix; + string postfix = "0000000"; + infixToPostfix(infix, postfix); + cout << postfix << endl; + + system("pause"); + return 0; +} \ No newline at end of file From 2cc239ca0c1fa0ea471f6222542dadbbb1f0b7f9 Mon Sep 17 00:00:00 2001 From: Victoria Date: Sun, 28 Oct 2018 00:54:29 +0300 Subject: [PATCH 03/17] trying to make for brackets --- .../Infix to postfix.cpp | 40 ++++++++++++++----- .../from infix to postfix/main.cpp | 3 +- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp index c4c868b..60fac63 100644 --- a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp +++ b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp @@ -1,12 +1,14 @@ #include "Infix to postfix.h" bool isOperator(char const symbol); -bool ifOperatorHasHigherPriority(char const operatorCheck, char const operatorCompareWith); +bool ifOperatorHasHigherPriority(char const operatorCheck, char const operatorCompareWith, + bool wasOpeningBrake); void infixToPostfix(string & infix, string & toPostfix) { Stack s; int count = 0; + // bool wasOpeningBrake = false; for (int i = 0; i < (int)infix.size(); ++i) { if (!isOperator(infix[i])) @@ -14,8 +16,20 @@ void infixToPostfix(string & infix, string & toPostfix) toPostfix[count] = infix[i]; ++count; } + else if (infix[i] == '(' || infix[i] == ')') + { + /*if (infix[i] == '(') + { + wasOpeningBrake = true; + } + else + { + wasOpeningBrake = false; + }*/ + } else { + while (!s.isEmpty()) { if (ifOperatorHasHigherPriority(infix[i], s.peek())) @@ -44,21 +58,29 @@ bool isOperator(char const symbol) return (symbol == '+' || symbol == '-' || symbol == '*' || symbol == '/'); } -bool ifOperatorHasHigherPriority(char const operatorCheck, char const operatorCompareWith) +bool ifOperatorHasHigherPriority(char const operatorCheck, char const operatorCompareWith, + bool wasOpeningBrake) { - if (operatorCheck == '+' || operatorCheck == '-') - { - return false; - } - else + if (!wasOpeningBrake) { - if (operatorCompareWith == '*' || operatorCompareWith == '/') + if (operatorCheck == '+' || operatorCheck == '-') { return false; } else { - return true; + if (operatorCompareWith == '*' || operatorCompareWith == '/') + { + return false; + } + else + { + return true; + } } } + else + { + + } } \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/main.cpp b/hw6/from infix to postfix/from infix to postfix/main.cpp index 5f54c9b..d7c5875 100644 --- a/hw6/from infix to postfix/from infix to postfix/main.cpp +++ b/hw6/from infix to postfix/from infix to postfix/main.cpp @@ -1,4 +1,5 @@ #include +#include #include "Infix to postfix.h" using namespace std; @@ -8,7 +9,7 @@ int main() string infix; cout << "Input infix expression\n"; cin >> infix; - string postfix = "0000000"; + string postfix = "!!!!!!!!!!"; infixToPostfix(infix, postfix); cout << postfix << endl; From c68b9429d2731542b20dc163e10bdfdfef65d4c3 Mon Sep 17 00:00:00 2001 From: Victoria Date: Sun, 28 Oct 2018 19:18:08 +0300 Subject: [PATCH 04/17] trying to make with brakes --- .../Infix to postfix.cpp | 45 +------------------ 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp index 60fac63..e5dd354 100644 --- a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp +++ b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp @@ -7,50 +7,7 @@ bool ifOperatorHasHigherPriority(char const operatorCheck, char const operatorCo void infixToPostfix(string & infix, string & toPostfix) { Stack s; - int count = 0; - // bool wasOpeningBrake = false; - for (int i = 0; i < (int)infix.size(); ++i) - { - if (!isOperator(infix[i])) - { - toPostfix[count] = infix[i]; - ++count; - } - else if (infix[i] == '(' || infix[i] == ')') - { - /*if (infix[i] == '(') - { - wasOpeningBrake = true; - } - else - { - wasOpeningBrake = false; - }*/ - } - else - { - - while (!s.isEmpty()) - { - if (ifOperatorHasHigherPriority(infix[i], s.peek())) - { - break; - } - else - { - toPostfix[count] = s.peek(); - s.pop(); - ++count; - } - } - s.push(infix[i]); - } - } - while (!s.isEmpty()) - { - toPostfix[count] = s.peek(); - s.pop(); - } + } bool isOperator(char const symbol) From ea69ae459b919006b16fec84a1a4cdd0d23e26ac Mon Sep 17 00:00:00 2001 From: Victoria Date: Sun, 28 Oct 2018 23:59:15 +0300 Subject: [PATCH 05/17] seems correct even with brackets --- .../Infix to postfix.cpp | 103 ++++++++++++++---- .../from infix to postfix/Infix to postfix.h | 2 +- 2 files changed, 83 insertions(+), 22 deletions(-) diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp index e5dd354..fa214e2 100644 --- a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp +++ b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp @@ -1,43 +1,104 @@ #include "Infix to postfix.h" bool isOperator(char const symbol); -bool ifOperatorHasHigherPriority(char const operatorCheck, char const operatorCompareWith, - bool wasOpeningBrake); +bool isRoundBracket(char const symbol); +void doIfOperator(Stack & s, string & toPostrix, int & currentIndex, char const currentSymbol); +bool isPlusOrMinus(char const symbol); +bool isMultOrDiv(char const symbol); -void infixToPostfix(string & infix, string & toPostfix) +int infixToPostfix(string & infix, string & toPostfix) { Stack s; - -} - -bool isOperator(char const symbol) -{ - return (symbol == '+' || symbol == '-' || symbol == '*' || symbol == '/'); -} - -bool ifOperatorHasHigherPriority(char const operatorCheck, char const operatorCompareWith, - bool wasOpeningBrake) -{ - if (!wasOpeningBrake) + int currentIndex = 0; + for (int i = 0; i < (int)infix.size(); ++i) { - if (operatorCheck == '+' || operatorCheck == '-') + if (!isOperator(infix[i]) && !isRoundBracket(infix[i])) { - return false; + toPostfix[currentIndex] = infix[i]; + ++currentIndex; } else { - if (operatorCompareWith == '*' || operatorCompareWith == '/') + if (isOperator(infix[i])) { - return false; + doIfOperator(s, toPostfix, currentIndex, infix[i]); } else { - return true; + if (infix[i] == ')' && s.isEmpty()) + { + cout << "Infix expression is incorrect" << endl; + return -1; + } + else if (infix[i] == ')' && isOperator(s.peek())) + { + toPostfix[currentIndex] = s.peek(); + s.pop(); + ++currentIndex; + if (infix[i] == ')' && s.peek() == '(') + { + s.pop(); + } + } + else if (infix[i] == '(' && (s.isEmpty() || isOperator(s.peek()) || s.peek() == '(')) + { + s.push(infix[i]); + } } } } - else + while (!s.isEmpty()) { + toPostfix[currentIndex] = s.peek(); + s.pop(); + ++currentIndex; + } +} + +bool isOperator(char const symbol) +{ + return (symbol == '+' || symbol == '-' || symbol == '*' || symbol == '/'); +} + +bool isRoundBracket(char const symbol) +{ + return (symbol == '(' || symbol == ')'); +} +void doIfOperator(Stack & s, string & toPostrix, int & currentIndex, char const currentSymbol) +{ + if (s.isEmpty()) + { + s.push(currentSymbol); + } + else + { + if (isMultOrDiv(currentSymbol) && isPlusOrMinus(s.peek()) || s.peek() == ')') + { + s.push(currentSymbol); + } + else if (s.peek() == '(') + { + s.push(currentSymbol); + } + else + { + // , - + // , - + toPostrix[currentIndex] = s.peek(); + s.pop(); + s.push(currentSymbol); + ++currentIndex; + } } +} + +bool isPlusOrMinus(char const symbol) +{ + return (symbol == '+' || symbol == '-'); +} + +bool isMultOrDiv(char const symbol) +{ + return (symbol == '*' || symbol == '/'); } \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h index c142aa6..69a0d01 100644 --- a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h +++ b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h @@ -5,4 +5,4 @@ using namespace std; -void infixToPostfix(string & infix, string & toPostfix); \ No newline at end of file +int infixToPostfix(string & infix, string & toPostfix); \ No newline at end of file From da5e83660ae162ed9ac081046ff0a9b2a8072e2f Mon Sep 17 00:00:00 2001 From: Victoria Date: Mon, 29 Oct 2018 00:10:28 +0300 Subject: [PATCH 06/17] made better --- .../from infix to postfix/Infix to postfix.cpp | 10 ++++++++-- .../from infix to postfix/Infix to postfix.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp index fa214e2..071a44e 100644 --- a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp +++ b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp @@ -6,7 +6,7 @@ void doIfOperator(Stack & s, string & toPostrix, int & currentIndex, char const bool isPlusOrMinus(char const symbol); bool isMultOrDiv(char const symbol); -int infixToPostfix(string & infix, string & toPostfix) +int infixToPostfix(string const & infix, string & toPostfix) { Stack s; int currentIndex = 0; @@ -35,7 +35,7 @@ int infixToPostfix(string & infix, string & toPostfix) toPostfix[currentIndex] = s.peek(); s.pop(); ++currentIndex; - if (infix[i] == ')' && s.peek() == '(') + if (s.peek() == '(') { s.pop(); } @@ -49,10 +49,16 @@ int infixToPostfix(string & infix, string & toPostfix) } while (!s.isEmpty()) { + if (isRoundBracket(s.peek())) + { + cout << "Infix expression is incorrect" << endl; + return -1; + } toPostfix[currentIndex] = s.peek(); s.pop(); ++currentIndex; } + return 0; } bool isOperator(char const symbol) diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h index 69a0d01..ba84706 100644 --- a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h +++ b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h @@ -5,4 +5,4 @@ using namespace std; -int infixToPostfix(string & infix, string & toPostfix); \ No newline at end of file +int infixToPostfix(string const & infix, string & toPostfix); \ No newline at end of file From be25d6f94c6c17dff3c22404ee4c8009792fa03b Mon Sep 17 00:00:00 2001 From: Victoria Date: Mon, 29 Oct 2018 00:28:27 +0300 Subject: [PATCH 07/17] made better --- .../Infix to postfix.cpp | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp index 071a44e..2461388 100644 --- a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp +++ b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp @@ -3,6 +3,7 @@ bool isOperator(char const symbol); bool isRoundBracket(char const symbol); void doIfOperator(Stack & s, string & toPostrix, int & currentIndex, char const currentSymbol); +int doIfRoundBracket(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol); bool isPlusOrMinus(char const symbol); bool isMultOrDiv(char const symbol); @@ -25,25 +26,11 @@ int infixToPostfix(string const & infix, string & toPostfix) } else { - if (infix[i] == ')' && s.isEmpty()) + if (doIfRoundBracket(s, toPostfix, currentIndex, infix[i]) == -1) { cout << "Infix expression is incorrect" << endl; return -1; } - else if (infix[i] == ')' && isOperator(s.peek())) - { - toPostfix[currentIndex] = s.peek(); - s.pop(); - ++currentIndex; - if (s.peek() == '(') - { - s.pop(); - } - } - else if (infix[i] == '(' && (s.isEmpty() || isOperator(s.peek()) || s.peek() == '(')) - { - s.push(infix[i]); - } } } } @@ -55,8 +42,8 @@ int infixToPostfix(string const & infix, string & toPostfix) return -1; } toPostfix[currentIndex] = s.peek(); - s.pop(); ++currentIndex; + s.pop(); } return 0; } @@ -92,13 +79,37 @@ void doIfOperator(Stack & s, string & toPostrix, int & currentIndex, char const // , - // , - toPostrix[currentIndex] = s.peek(); + ++currentIndex; s.pop(); s.push(currentSymbol); - ++currentIndex; } } } +int doIfRoundBracket(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol) +{ + if (currentSymbol == ')' && s.isEmpty()) + { + return -1; + } + else if (currentSymbol == ')' && isOperator(s.peek())) + { + toPostfix[currentIndex] = s.peek(); + ++currentIndex; + s.pop(); + if (s.peek() == '(') + { + s.pop(); + } + } + else + { + // , + s.push(currentSymbol); + } + return 0; +} + bool isPlusOrMinus(char const symbol) { return (symbol == '+' || symbol == '-'); From 7e2d02bb1a2354d57d3405f9d9bd38907a90e1fe Mon Sep 17 00:00:00 2001 From: Victoria Date: Mon, 29 Oct 2018 00:37:54 +0300 Subject: [PATCH 08/17] finished --- .../Infix to postfix.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp index 2461388..62219ba 100644 --- a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp +++ b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp @@ -4,6 +4,7 @@ bool isOperator(char const symbol); bool isRoundBracket(char const symbol); void doIfOperator(Stack & s, string & toPostrix, int & currentIndex, char const currentSymbol); int doIfRoundBracket(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol); +int popAllOperators(Stack & s, string & toPostfix, int & currentIndex); bool isPlusOrMinus(char const symbol); bool isMultOrDiv(char const symbol); @@ -36,14 +37,10 @@ int infixToPostfix(string const & infix, string & toPostfix) } while (!s.isEmpty()) { - if (isRoundBracket(s.peek())) + if (popAllOperators(s, toPostfix, currentIndex) == -1) { - cout << "Infix expression is incorrect" << endl; return -1; } - toPostfix[currentIndex] = s.peek(); - ++currentIndex; - s.pop(); } return 0; } @@ -110,6 +107,18 @@ int doIfRoundBracket(Stack & s, string & toPostfix, int & currentIndex, char con return 0; } +int popAllOperators(Stack & s, string & toPostfix, int & currentIndex) +{ + if (isRoundBracket(s.peek())) + { + return -1; + } + toPostfix[currentIndex] = s.peek(); + ++currentIndex; + s.pop(); + return 0; +} + bool isPlusOrMinus(char const symbol) { return (symbol == '+' || symbol == '-'); From 4c22dfd7df8c067d94c3a596ed028339073f1d23 Mon Sep 17 00:00:00 2001 From: Victoria Date: Mon, 29 Oct 2018 13:41:33 +0300 Subject: [PATCH 09/17] made kaka --- hw6/from infix to postfix/from infix to postfix/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw6/from infix to postfix/from infix to postfix/main.cpp b/hw6/from infix to postfix/from infix to postfix/main.cpp index d7c5875..03eec08 100644 --- a/hw6/from infix to postfix/from infix to postfix/main.cpp +++ b/hw6/from infix to postfix/from infix to postfix/main.cpp @@ -9,8 +9,8 @@ int main() string infix; cout << "Input infix expression\n"; cin >> infix; - string postfix = "!!!!!!!!!!"; - infixToPostfix(infix, postfix); + string postfix = " "; + infixToPostfix(infix, postfix); cout << postfix << endl; system("pause"); From 379738804e2db4f7c570fb1b536f3f19c84dbbd1 Mon Sep 17 00:00:00 2001 From: Victoria Date: Mon, 29 Oct 2018 20:02:16 +0300 Subject: [PATCH 10/17] made better --- .../from infix to postfix/Infix to postfix.cpp | 10 +++++----- .../from infix to postfix/main.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp index 62219ba..4425ba4 100644 --- a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp +++ b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp @@ -16,7 +16,7 @@ int infixToPostfix(string const & infix, string & toPostfix) { if (!isOperator(infix[i]) && !isRoundBracket(infix[i])) { - toPostfix[currentIndex] = infix[i]; + toPostfix += infix[i]; ++currentIndex; } else @@ -55,7 +55,7 @@ bool isRoundBracket(char const symbol) return (symbol == '(' || symbol == ')'); } -void doIfOperator(Stack & s, string & toPostrix, int & currentIndex, char const currentSymbol) +void doIfOperator(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol) { if (s.isEmpty()) { @@ -75,7 +75,7 @@ void doIfOperator(Stack & s, string & toPostrix, int & currentIndex, char const { // , - // , - - toPostrix[currentIndex] = s.peek(); + toPostfix += s.peek(); ++currentIndex; s.pop(); s.push(currentSymbol); @@ -91,7 +91,7 @@ int doIfRoundBracket(Stack & s, string & toPostfix, int & currentIndex, char con } else if (currentSymbol == ')' && isOperator(s.peek())) { - toPostfix[currentIndex] = s.peek(); + toPostfix += s.peek(); ++currentIndex; s.pop(); if (s.peek() == '(') @@ -113,7 +113,7 @@ int popAllOperators(Stack & s, string & toPostfix, int & currentIndex) { return -1; } - toPostfix[currentIndex] = s.peek(); + toPostfix += s.peek(); ++currentIndex; s.pop(); return 0; diff --git a/hw6/from infix to postfix/from infix to postfix/main.cpp b/hw6/from infix to postfix/from infix to postfix/main.cpp index 03eec08..6a7cee3 100644 --- a/hw6/from infix to postfix/from infix to postfix/main.cpp +++ b/hw6/from infix to postfix/from infix to postfix/main.cpp @@ -9,7 +9,7 @@ int main() string infix; cout << "Input infix expression\n"; cin >> infix; - string postfix = " "; + string postfix; infixToPostfix(infix, postfix); cout << postfix << endl; From 67d7431612718a9f9c66227cd9b74dba2e4390a1 Mon Sep 17 00:00:00 2001 From: Victoria Date: Fri, 21 Dec 2018 13:41:49 +0300 Subject: [PATCH 11/17] added makefile --- .../from infix to postfix/Makefile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 hw6/from infix to postfix/from infix to postfix/Makefile diff --git a/hw6/from infix to postfix/from infix to postfix/Makefile b/hw6/from infix to postfix/from infix to postfix/Makefile new file mode 100644 index 0000000..97ee117 --- /dev/null +++ b/hw6/from infix to postfix/from infix to postfix/Makefile @@ -0,0 +1,14 @@ +from_infix_to_postfix: from_infix_to_postfix Element.o Infix_to_postfix.o Stack.o main.o + g++ -o from_infix_to_postfix Element.o Infix_to_postfix.o Stack.o main.o + +Infix_to_postfix.o: Infix to postfix.cpp Infix to postfix.h + g++ -c Infix to postfix.cpp +Element.o: Element.cpp Element.h + g++ -c Element.cpp +main.o: main.cpp Infix to postfix.h + g++ -c main.cpp +Stack.o: Stack.cpp Stack.h Element.h + g++ -c Stack.cpp + +clean: + del *.o \ No newline at end of file From 27ff3cee9d83fadbba93a97a554d0ee81c276f49 Mon Sep 17 00:00:00 2001 From: Victoria Date: Sat, 22 Dec 2018 13:24:39 +0300 Subject: [PATCH 12/17] renamed without spaced and added Makefile --- .../from infix to postfix.sln | 0 .../from infix to postfix/Element.cpp | 0 .../from infix to postfix/Element.h | 0 .../Infix to postfix.cpp | 0 .../from infix to postfix/Infix to postfix.h | 0 .../from infix to postfix/Makefile | 0 .../from infix to postfix/Stack.cpp | 0 .../from infix to postfix/Stack.h | 0 .../from infix to postfix.vcxproj | 0 .../from infix to postfix.vcxproj.filters | 0 .../from infix to postfix/main.cpp | 0 hw6/toPostfix/toPostfix/toPostfix.sln | 31 +++++ hw6/toPostfix/toPostfix/toPostfix/Element.cpp | 13 ++ hw6/toPostfix/toPostfix/toPostfix/Element.h | 9 ++ hw6/toPostfix/toPostfix/toPostfix/Makefile | Bin 0 -> 682 bytes hw6/toPostfix/toPostfix/toPostfix/Stack.cpp | 65 +++++++++ hw6/toPostfix/toPostfix/toPostfix/Stack.h | 28 ++++ hw6/toPostfix/toPostfix/toPostfix/main.cpp | 19 +++ .../toPostfix/toPostfix/toPostfix.cpp | 130 +++++++++++++++++ hw6/toPostfix/toPostfix/toPostfix/toPostfix.h | 8 ++ .../toPostfix/toPostfix/toPostfix.vcxproj | 131 ++++++++++++++++++ .../toPostfix/toPostfix.vcxproj.filters | 42 ++++++ 22 files changed, 476 insertions(+) rename {hw6/from infix to postfix => from infix to postfix}/from infix to postfix.sln (100%) rename {hw6/from infix to postfix => from infix to postfix}/from infix to postfix/Element.cpp (100%) rename {hw6/from infix to postfix => from infix to postfix}/from infix to postfix/Element.h (100%) rename {hw6/from infix to postfix => from infix to postfix}/from infix to postfix/Infix to postfix.cpp (100%) rename {hw6/from infix to postfix => from infix to postfix}/from infix to postfix/Infix to postfix.h (100%) rename {hw6/from infix to postfix => from infix to postfix}/from infix to postfix/Makefile (100%) rename {hw6/from infix to postfix => from infix to postfix}/from infix to postfix/Stack.cpp (100%) rename {hw6/from infix to postfix => from infix to postfix}/from infix to postfix/Stack.h (100%) rename {hw6/from infix to postfix => from infix to postfix}/from infix to postfix/from infix to postfix.vcxproj (100%) rename {hw6/from infix to postfix => from infix to postfix}/from infix to postfix/from infix to postfix.vcxproj.filters (100%) rename {hw6/from infix to postfix => from infix to postfix}/from infix to postfix/main.cpp (100%) create mode 100644 hw6/toPostfix/toPostfix/toPostfix.sln create mode 100644 hw6/toPostfix/toPostfix/toPostfix/Element.cpp create mode 100644 hw6/toPostfix/toPostfix/toPostfix/Element.h create mode 100644 hw6/toPostfix/toPostfix/toPostfix/Makefile create mode 100644 hw6/toPostfix/toPostfix/toPostfix/Stack.cpp create mode 100644 hw6/toPostfix/toPostfix/toPostfix/Stack.h create mode 100644 hw6/toPostfix/toPostfix/toPostfix/main.cpp create mode 100644 hw6/toPostfix/toPostfix/toPostfix/toPostfix.cpp create mode 100644 hw6/toPostfix/toPostfix/toPostfix/toPostfix.h create mode 100644 hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj create mode 100644 hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj.filters diff --git a/hw6/from infix to postfix/from infix to postfix.sln b/from infix to postfix/from infix to postfix.sln similarity index 100% rename from hw6/from infix to postfix/from infix to postfix.sln rename to from infix to postfix/from infix to postfix.sln diff --git a/hw6/from infix to postfix/from infix to postfix/Element.cpp b/from infix to postfix/from infix to postfix/Element.cpp similarity index 100% rename from hw6/from infix to postfix/from infix to postfix/Element.cpp rename to from infix to postfix/from infix to postfix/Element.cpp diff --git a/hw6/from infix to postfix/from infix to postfix/Element.h b/from infix to postfix/from infix to postfix/Element.h similarity index 100% rename from hw6/from infix to postfix/from infix to postfix/Element.h rename to from infix to postfix/from infix to postfix/Element.h diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp b/from infix to postfix/from infix to postfix/Infix to postfix.cpp similarity index 100% rename from hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp rename to from infix to postfix/from infix to postfix/Infix to postfix.cpp diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h b/from infix to postfix/from infix to postfix/Infix to postfix.h similarity index 100% rename from hw6/from infix to postfix/from infix to postfix/Infix to postfix.h rename to from infix to postfix/from infix to postfix/Infix to postfix.h diff --git a/hw6/from infix to postfix/from infix to postfix/Makefile b/from infix to postfix/from infix to postfix/Makefile similarity index 100% rename from hw6/from infix to postfix/from infix to postfix/Makefile rename to from infix to postfix/from infix to postfix/Makefile diff --git a/hw6/from infix to postfix/from infix to postfix/Stack.cpp b/from infix to postfix/from infix to postfix/Stack.cpp similarity index 100% rename from hw6/from infix to postfix/from infix to postfix/Stack.cpp rename to from infix to postfix/from infix to postfix/Stack.cpp diff --git a/hw6/from infix to postfix/from infix to postfix/Stack.h b/from infix to postfix/from infix to postfix/Stack.h similarity index 100% rename from hw6/from infix to postfix/from infix to postfix/Stack.h rename to from infix to postfix/from infix to postfix/Stack.h diff --git a/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj b/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj similarity index 100% rename from hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj rename to from infix to postfix/from infix to postfix/from infix to postfix.vcxproj diff --git a/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters b/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters similarity index 100% rename from hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters rename to from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters diff --git a/hw6/from infix to postfix/from infix to postfix/main.cpp b/from infix to postfix/from infix to postfix/main.cpp similarity index 100% rename from hw6/from infix to postfix/from infix to postfix/main.cpp rename to from infix to postfix/from infix to postfix/main.cpp diff --git a/hw6/toPostfix/toPostfix/toPostfix.sln b/hw6/toPostfix/toPostfix/toPostfix.sln new file mode 100644 index 0000000..b868db8 --- /dev/null +++ b/hw6/toPostfix/toPostfix/toPostfix.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toPostfix", "toPostfix\toPostfix.vcxproj", "{326EF805-B509-486B-9522-8892D74DD3F2}" +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 + {326EF805-B509-486B-9522-8892D74DD3F2}.Debug|x64.ActiveCfg = Debug|x64 + {326EF805-B509-486B-9522-8892D74DD3F2}.Debug|x64.Build.0 = Debug|x64 + {326EF805-B509-486B-9522-8892D74DD3F2}.Debug|x86.ActiveCfg = Debug|Win32 + {326EF805-B509-486B-9522-8892D74DD3F2}.Debug|x86.Build.0 = Debug|Win32 + {326EF805-B509-486B-9522-8892D74DD3F2}.Release|x64.ActiveCfg = Release|x64 + {326EF805-B509-486B-9522-8892D74DD3F2}.Release|x64.Build.0 = Release|x64 + {326EF805-B509-486B-9522-8892D74DD3F2}.Release|x86.ActiveCfg = Release|Win32 + {326EF805-B509-486B-9522-8892D74DD3F2}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D2CDE4B5-B52B-40C2-A5B7-65ED9D7D595C} + EndGlobalSection +EndGlobal diff --git a/hw6/toPostfix/toPostfix/toPostfix/Element.cpp b/hw6/toPostfix/toPostfix/toPostfix/Element.cpp new file mode 100644 index 0000000..8bbeb35 --- /dev/null +++ b/hw6/toPostfix/toPostfix/toPostfix/Element.cpp @@ -0,0 +1,13 @@ +#include "Element.h" + +Element::Element(char data = '\0') +{ + this->data = data; + this->next = nullptr; +} + +Element::~Element() +{ + this->data = '\0'; + this->next = nullptr; +} \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/Element.h b/hw6/toPostfix/toPostfix/toPostfix/Element.h new file mode 100644 index 0000000..f15288d --- /dev/null +++ b/hw6/toPostfix/toPostfix/toPostfix/Element.h @@ -0,0 +1,9 @@ +#pragma once + +struct Element +{ + Element(char data); + ~Element(); + char data; + Element* next; +}; \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/Makefile b/hw6/toPostfix/toPostfix/toPostfix/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..984c5ee3e563895fc045bd8b238fae67152a2221 GIT binary patch literal 682 zcmb`FJr2S!429nc5_iZ9f&+ACN8$uk_-RE8NOa)zl;^f-QrB!KilW%h{_Monext; + temp->next = nullptr; + delete temp; + temp = nullptr; + } +} + +void Stack::push(char data) +{ + auto* newElement = new Element(data); + if (!isEmpty()) + { + newElement->next = head; + } + head = newElement; +} + +int Stack::pop() +{ + if (!isEmpty()) + { + auto* temp = head->next; + head->next = nullptr; + delete head; + head = nullptr; + head = temp; + return 0; + } + else + { + return -1; + } +} + +char Stack::peek() +{ + if (!isEmpty()) + { + return head->data; + } + else + { + cout << "Stack is empty\n"; + return '\0'; + } +} + +bool Stack::isEmpty() +{ + return head == nullptr; +} \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/Stack.h b/hw6/toPostfix/toPostfix/toPostfix/Stack.h new file mode 100644 index 0000000..9a208c5 --- /dev/null +++ b/hw6/toPostfix/toPostfix/toPostfix/Stack.h @@ -0,0 +1,28 @@ +#pragma once +#include + +using namespace std; + +struct Element; + +struct Stack +{ + // + Stack(); + // + ~Stack(); + // + + // + + // + void push(char data); + // + int pop(); + // + char peek(); + // + bool isEmpty(); +private: + Element * head; +}; \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/main.cpp b/hw6/toPostfix/toPostfix/toPostfix/main.cpp new file mode 100644 index 0000000..d96caa5 --- /dev/null +++ b/hw6/toPostfix/toPostfix/toPostfix/main.cpp @@ -0,0 +1,19 @@ +#include +#include +#include "toPostfix.h" + +using namespace std; + +int main() +{ + string infix; + cout << "Input expression to convert it to postfix\n"; + cin >> infix; + string postfix; + toPostfix(infix, postfix); + cout << "Result is\n"; + cout << postfix << endl; + + system("pause"); + return 0; +} \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/toPostfix.cpp b/hw6/toPostfix/toPostfix/toPostfix/toPostfix.cpp new file mode 100644 index 0000000..0ffb927 --- /dev/null +++ b/hw6/toPostfix/toPostfix/toPostfix/toPostfix.cpp @@ -0,0 +1,130 @@ +#include "toPostfix.h" + +bool isOperator(char const symbol); +bool isRoundBracket(char const symbol); +void doIfOperator(Stack & s, string & toPostrix, int & currentIndex, char const currentSymbol); +int doIfRoundBracket(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol); +int popAllOperators(Stack & s, string & toPostfix, int & currentIndex); +bool isPlusOrMinus(char const symbol); +bool isMultOrDiv(char const symbol); + +int toPostfix(string const & infix, string & toPostfix) +{ + Stack s; + int currentIndex = 0; + for (int i = 0; i < (int)infix.size(); ++i) + { + if (!isOperator(infix[i]) && !isRoundBracket(infix[i])) + { + toPostfix += infix[i]; + ++currentIndex; + } + else + { + if (isOperator(infix[i])) + { + doIfOperator(s, toPostfix, currentIndex, infix[i]); + } + else + { + if (doIfRoundBracket(s, toPostfix, currentIndex, infix[i]) == -1) + { + cout << "Infix expression is incorrect" << endl; + return -1; + } + } + } + } + while (!s.isEmpty()) + { + if (popAllOperators(s, toPostfix, currentIndex) == -1) + { + return -1; + } + } + return 0; +} + +bool isOperator(char const symbol) +{ + return (symbol == '+' || symbol == '-' || symbol == '*' || symbol == '/'); +} + +bool isRoundBracket(char const symbol) +{ + return (symbol == '(' || symbol == ')'); +} + +void doIfOperator(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol) +{ + if (s.isEmpty()) + { + s.push(currentSymbol); + } + else + { + if (isMultOrDiv(currentSymbol) && isPlusOrMinus(s.peek()) || s.peek() == ')') + { + s.push(currentSymbol); + } + else if (s.peek() == '(') + { + s.push(currentSymbol); + } + else + { + // òåêóùèé ñèìâîë óìíîæ èëè äåë, ïîñëåäíèé ýëåìåíò íà ñòåêå - óìíîæèòü èëè äåëèòü + // òåêóùèé ýëåìåíò ïëþñ èëè ìèíóñ, ïîñëåäíèé ýëåìåíò íà ñòåêå - îïåðàòîð + toPostfix += s.peek(); + ++currentIndex; + s.pop(); + s.push(currentSymbol); + } + } +} + +int doIfRoundBracket(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol) +{ + if (currentSymbol == ')' && s.isEmpty()) + { + return -1; + } + else if (currentSymbol == ')' && isOperator(s.peek())) + { + toPostfix += s.peek(); + ++currentIndex; + s.pop(); + if (s.peek() == '(') + { + s.pop(); + } + } + else + { + // åñëè ñêîáêà êðóãëàÿ, òî ïðîñòî êëàäåì åå â ñòåê + s.push(currentSymbol); + } + return 0; +} + +int popAllOperators(Stack & s, string & toPostfix, int & currentIndex) +{ + if (isRoundBracket(s.peek())) + { + return -1; + } + toPostfix += s.peek(); + ++currentIndex; + s.pop(); + return 0; +} + +bool isPlusOrMinus(char const symbol) +{ + return (symbol == '+' || symbol == '-'); +} + +bool isMultOrDiv(char const symbol) +{ + return (symbol == '*' || symbol == '/'); +} \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/toPostfix.h b/hw6/toPostfix/toPostfix/toPostfix/toPostfix.h new file mode 100644 index 0000000..ceeb636 --- /dev/null +++ b/hw6/toPostfix/toPostfix/toPostfix/toPostfix.h @@ -0,0 +1,8 @@ +#pragma once +#include +#include +#include "Stack.h" + +using namespace std; + +int toPostfix(string const & infix, string & toPostfix); \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj b/hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj new file mode 100644 index 0000000..27f7378 --- /dev/null +++ b/hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj @@ -0,0 +1,131 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {326EF805-B509-486B-9522-8892D74DD3F2} + toPostfix + 10.0.17134.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + true + + + + + Level3 + Disabled + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj.filters b/hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj.filters new file mode 100644 index 0000000..2ecb9ba --- /dev/null +++ b/hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj.filters @@ -0,0 +1,42 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;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 fa53dd5f1a62c999409f609c4dee11aced7ed859 Mon Sep 17 00:00:00 2001 From: Victoria Date: Sat, 22 Dec 2018 23:38:08 +0300 Subject: [PATCH 13/17] adds --- Makefile | 14 ++++++++++++++ hw6/toPostfix/toPostfix/toPostfix/Makefile | Bin 682 -> 0 bytes hw6/toPostfix/toPostfix/toPostfix/main.cpp | 1 - .../toPostfix/toPostfix/toPostfix.vcxproj | 8 ++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 Makefile delete mode 100644 hw6/toPostfix/toPostfix/toPostfix/Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7bc2955 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +toPostfix: Element.o toPostfix.o Stack.o main.o + g++ -o Element.o toPostfix.o Stack.o main.o + +toPostfix.o: toPostfix.cpp toPostfix.h + g++ -c toPostfix.cpp +Element.o: Element.cpp Element.h + g++ -c Element.cpp +main.o: main.cpp toPostfix.h + g++ -c main.cpp +Stack.o: Stack.cpp Stack.h Element.h + g++ -c Stack.cpp + +clean: + del *.o diff --git a/hw6/toPostfix/toPostfix/toPostfix/Makefile b/hw6/toPostfix/toPostfix/toPostfix/Makefile deleted file mode 100644 index 984c5ee3e563895fc045bd8b238fae67152a2221..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 682 zcmb`FJr2S!429nc5_iZ9f&+ACN8$uk_-RE8NOa)zl;^f-QrB!KilW%h{_Motrue true + + Console + @@ -85,6 +88,9 @@ true true + + Console + @@ -98,6 +104,7 @@ true true + Console @@ -112,6 +119,7 @@ true true + Console From bdfa4ab93ccd4669591e51b5e072424e1a6f3164 Mon Sep 17 00:00:00 2001 From: Victoria Date: Sat, 22 Dec 2018 23:43:29 +0300 Subject: [PATCH 14/17] adds --- .../from infix to postfix.sln | 0 .../from infix to postfix/Element.cpp | 0 .../from infix to postfix/Element.h | 0 .../Infix to postfix.cpp | 0 .../from infix to postfix/Infix to postfix.h | 0 .../from infix to postfix/Makefile | 0 .../from infix to postfix/Stack.cpp | 0 .../from infix to postfix/Stack.h | 0 .../from infix to postfix.vcxproj | 0 .../from infix to postfix.vcxproj.filters | 0 .../from infix to postfix/main.cpp | 0 hw6/toPostfix/toPostfix/toPostfix.sln | 31 ----- hw6/toPostfix/toPostfix/toPostfix/Element.cpp | 13 -- hw6/toPostfix/toPostfix/toPostfix/Element.h | 9 -- hw6/toPostfix/toPostfix/toPostfix/Stack.cpp | 65 --------- hw6/toPostfix/toPostfix/toPostfix/Stack.h | 28 ---- .../toPostfix/toPostfix/toPostfix.cpp | 130 ------------------ hw6/toPostfix/toPostfix/toPostfix/toPostfix.h | 8 -- .../toPostfix/toPostfix.vcxproj.filters | 42 ------ 19 files changed, 326 deletions(-) rename {from infix to postfix => hw6/from infix to postfix}/from infix to postfix.sln (100%) rename {from infix to postfix => hw6/from infix to postfix}/from infix to postfix/Element.cpp (100%) rename {from infix to postfix => hw6/from infix to postfix}/from infix to postfix/Element.h (100%) rename {from infix to postfix => hw6/from infix to postfix}/from infix to postfix/Infix to postfix.cpp (100%) rename {from infix to postfix => hw6/from infix to postfix}/from infix to postfix/Infix to postfix.h (100%) rename {from infix to postfix => hw6/from infix to postfix}/from infix to postfix/Makefile (100%) rename {from infix to postfix => hw6/from infix to postfix}/from infix to postfix/Stack.cpp (100%) rename {from infix to postfix => hw6/from infix to postfix}/from infix to postfix/Stack.h (100%) rename {from infix to postfix => hw6/from infix to postfix}/from infix to postfix/from infix to postfix.vcxproj (100%) rename {from infix to postfix => hw6/from infix to postfix}/from infix to postfix/from infix to postfix.vcxproj.filters (100%) rename {from infix to postfix => hw6/from infix to postfix}/from infix to postfix/main.cpp (100%) delete mode 100644 hw6/toPostfix/toPostfix/toPostfix.sln delete mode 100644 hw6/toPostfix/toPostfix/toPostfix/Element.cpp delete mode 100644 hw6/toPostfix/toPostfix/toPostfix/Element.h delete mode 100644 hw6/toPostfix/toPostfix/toPostfix/Stack.cpp delete mode 100644 hw6/toPostfix/toPostfix/toPostfix/Stack.h delete mode 100644 hw6/toPostfix/toPostfix/toPostfix/toPostfix.cpp delete mode 100644 hw6/toPostfix/toPostfix/toPostfix/toPostfix.h delete mode 100644 hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj.filters diff --git a/from infix to postfix/from infix to postfix.sln b/hw6/from infix to postfix/from infix to postfix.sln similarity index 100% rename from from infix to postfix/from infix to postfix.sln rename to hw6/from infix to postfix/from infix to postfix.sln diff --git a/from infix to postfix/from infix to postfix/Element.cpp b/hw6/from infix to postfix/from infix to postfix/Element.cpp similarity index 100% rename from from infix to postfix/from infix to postfix/Element.cpp rename to hw6/from infix to postfix/from infix to postfix/Element.cpp diff --git a/from infix to postfix/from infix to postfix/Element.h b/hw6/from infix to postfix/from infix to postfix/Element.h similarity index 100% rename from from infix to postfix/from infix to postfix/Element.h rename to hw6/from infix to postfix/from infix to postfix/Element.h diff --git a/from infix to postfix/from infix to postfix/Infix to postfix.cpp b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp similarity index 100% rename from from infix to postfix/from infix to postfix/Infix to postfix.cpp rename to hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp diff --git a/from infix to postfix/from infix to postfix/Infix to postfix.h b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h similarity index 100% rename from from infix to postfix/from infix to postfix/Infix to postfix.h rename to hw6/from infix to postfix/from infix to postfix/Infix to postfix.h diff --git a/from infix to postfix/from infix to postfix/Makefile b/hw6/from infix to postfix/from infix to postfix/Makefile similarity index 100% rename from from infix to postfix/from infix to postfix/Makefile rename to hw6/from infix to postfix/from infix to postfix/Makefile diff --git a/from infix to postfix/from infix to postfix/Stack.cpp b/hw6/from infix to postfix/from infix to postfix/Stack.cpp similarity index 100% rename from from infix to postfix/from infix to postfix/Stack.cpp rename to hw6/from infix to postfix/from infix to postfix/Stack.cpp diff --git a/from infix to postfix/from infix to postfix/Stack.h b/hw6/from infix to postfix/from infix to postfix/Stack.h similarity index 100% rename from from infix to postfix/from infix to postfix/Stack.h rename to hw6/from infix to postfix/from infix to postfix/Stack.h diff --git a/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj b/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj similarity index 100% rename from from infix to postfix/from infix to postfix/from infix to postfix.vcxproj rename to hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj diff --git a/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters b/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters similarity index 100% rename from from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters rename to hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters diff --git a/from infix to postfix/from infix to postfix/main.cpp b/hw6/from infix to postfix/from infix to postfix/main.cpp similarity index 100% rename from from infix to postfix/from infix to postfix/main.cpp rename to hw6/from infix to postfix/from infix to postfix/main.cpp diff --git a/hw6/toPostfix/toPostfix/toPostfix.sln b/hw6/toPostfix/toPostfix/toPostfix.sln deleted file mode 100644 index b868db8..0000000 --- a/hw6/toPostfix/toPostfix/toPostfix.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toPostfix", "toPostfix\toPostfix.vcxproj", "{326EF805-B509-486B-9522-8892D74DD3F2}" -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 - {326EF805-B509-486B-9522-8892D74DD3F2}.Debug|x64.ActiveCfg = Debug|x64 - {326EF805-B509-486B-9522-8892D74DD3F2}.Debug|x64.Build.0 = Debug|x64 - {326EF805-B509-486B-9522-8892D74DD3F2}.Debug|x86.ActiveCfg = Debug|Win32 - {326EF805-B509-486B-9522-8892D74DD3F2}.Debug|x86.Build.0 = Debug|Win32 - {326EF805-B509-486B-9522-8892D74DD3F2}.Release|x64.ActiveCfg = Release|x64 - {326EF805-B509-486B-9522-8892D74DD3F2}.Release|x64.Build.0 = Release|x64 - {326EF805-B509-486B-9522-8892D74DD3F2}.Release|x86.ActiveCfg = Release|Win32 - {326EF805-B509-486B-9522-8892D74DD3F2}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {D2CDE4B5-B52B-40C2-A5B7-65ED9D7D595C} - EndGlobalSection -EndGlobal diff --git a/hw6/toPostfix/toPostfix/toPostfix/Element.cpp b/hw6/toPostfix/toPostfix/toPostfix/Element.cpp deleted file mode 100644 index 8bbeb35..0000000 --- a/hw6/toPostfix/toPostfix/toPostfix/Element.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "Element.h" - -Element::Element(char data = '\0') -{ - this->data = data; - this->next = nullptr; -} - -Element::~Element() -{ - this->data = '\0'; - this->next = nullptr; -} \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/Element.h b/hw6/toPostfix/toPostfix/toPostfix/Element.h deleted file mode 100644 index f15288d..0000000 --- a/hw6/toPostfix/toPostfix/toPostfix/Element.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -struct Element -{ - Element(char data); - ~Element(); - char data; - Element* next; -}; \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/Stack.cpp b/hw6/toPostfix/toPostfix/toPostfix/Stack.cpp deleted file mode 100644 index 000c1f2..0000000 --- a/hw6/toPostfix/toPostfix/toPostfix/Stack.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "Stack.h" -#include "Element.h" - -Stack::Stack() -{ - head = nullptr; -} - -Stack::~Stack() -{ - auto* temp = head; - while (!isEmpty()) - { - temp = head; - head = temp->next; - temp->next = nullptr; - delete temp; - temp = nullptr; - } -} - -void Stack::push(char data) -{ - auto* newElement = new Element(data); - if (!isEmpty()) - { - newElement->next = head; - } - head = newElement; -} - -int Stack::pop() -{ - if (!isEmpty()) - { - auto* temp = head->next; - head->next = nullptr; - delete head; - head = nullptr; - head = temp; - return 0; - } - else - { - return -1; - } -} - -char Stack::peek() -{ - if (!isEmpty()) - { - return head->data; - } - else - { - cout << "Stack is empty\n"; - return '\0'; - } -} - -bool Stack::isEmpty() -{ - return head == nullptr; -} \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/Stack.h b/hw6/toPostfix/toPostfix/toPostfix/Stack.h deleted file mode 100644 index 9a208c5..0000000 --- a/hw6/toPostfix/toPostfix/toPostfix/Stack.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include - -using namespace std; - -struct Element; - -struct Stack -{ - // - Stack(); - // - ~Stack(); - // - - // - - // - void push(char data); - // - int pop(); - // - char peek(); - // - bool isEmpty(); -private: - Element * head; -}; \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/toPostfix.cpp b/hw6/toPostfix/toPostfix/toPostfix/toPostfix.cpp deleted file mode 100644 index 0ffb927..0000000 --- a/hw6/toPostfix/toPostfix/toPostfix/toPostfix.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "toPostfix.h" - -bool isOperator(char const symbol); -bool isRoundBracket(char const symbol); -void doIfOperator(Stack & s, string & toPostrix, int & currentIndex, char const currentSymbol); -int doIfRoundBracket(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol); -int popAllOperators(Stack & s, string & toPostfix, int & currentIndex); -bool isPlusOrMinus(char const symbol); -bool isMultOrDiv(char const symbol); - -int toPostfix(string const & infix, string & toPostfix) -{ - Stack s; - int currentIndex = 0; - for (int i = 0; i < (int)infix.size(); ++i) - { - if (!isOperator(infix[i]) && !isRoundBracket(infix[i])) - { - toPostfix += infix[i]; - ++currentIndex; - } - else - { - if (isOperator(infix[i])) - { - doIfOperator(s, toPostfix, currentIndex, infix[i]); - } - else - { - if (doIfRoundBracket(s, toPostfix, currentIndex, infix[i]) == -1) - { - cout << "Infix expression is incorrect" << endl; - return -1; - } - } - } - } - while (!s.isEmpty()) - { - if (popAllOperators(s, toPostfix, currentIndex) == -1) - { - return -1; - } - } - return 0; -} - -bool isOperator(char const symbol) -{ - return (symbol == '+' || symbol == '-' || symbol == '*' || symbol == '/'); -} - -bool isRoundBracket(char const symbol) -{ - return (symbol == '(' || symbol == ')'); -} - -void doIfOperator(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol) -{ - if (s.isEmpty()) - { - s.push(currentSymbol); - } - else - { - if (isMultOrDiv(currentSymbol) && isPlusOrMinus(s.peek()) || s.peek() == ')') - { - s.push(currentSymbol); - } - else if (s.peek() == '(') - { - s.push(currentSymbol); - } - else - { - // òåêóùèé ñèìâîë óìíîæ èëè äåë, ïîñëåäíèé ýëåìåíò íà ñòåêå - óìíîæèòü èëè äåëèòü - // òåêóùèé ýëåìåíò ïëþñ èëè ìèíóñ, ïîñëåäíèé ýëåìåíò íà ñòåêå - îïåðàòîð - toPostfix += s.peek(); - ++currentIndex; - s.pop(); - s.push(currentSymbol); - } - } -} - -int doIfRoundBracket(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol) -{ - if (currentSymbol == ')' && s.isEmpty()) - { - return -1; - } - else if (currentSymbol == ')' && isOperator(s.peek())) - { - toPostfix += s.peek(); - ++currentIndex; - s.pop(); - if (s.peek() == '(') - { - s.pop(); - } - } - else - { - // åñëè ñêîáêà êðóãëàÿ, òî ïðîñòî êëàäåì åå â ñòåê - s.push(currentSymbol); - } - return 0; -} - -int popAllOperators(Stack & s, string & toPostfix, int & currentIndex) -{ - if (isRoundBracket(s.peek())) - { - return -1; - } - toPostfix += s.peek(); - ++currentIndex; - s.pop(); - return 0; -} - -bool isPlusOrMinus(char const symbol) -{ - return (symbol == '+' || symbol == '-'); -} - -bool isMultOrDiv(char const symbol) -{ - return (symbol == '*' || symbol == '/'); -} \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/toPostfix.h b/hw6/toPostfix/toPostfix/toPostfix/toPostfix.h deleted file mode 100644 index ceeb636..0000000 --- a/hw6/toPostfix/toPostfix/toPostfix/toPostfix.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include -#include -#include "Stack.h" - -using namespace std; - -int toPostfix(string const & infix, string & toPostfix); \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj.filters b/hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj.filters deleted file mode 100644 index 2ecb9ba..0000000 --- a/hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj.filters +++ /dev/null @@ -1,42 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;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 49a98048324d563a55238c7a203dc5114adfd0b5 Mon Sep 17 00:00:00 2001 From: Victoria Date: Sat, 22 Dec 2018 23:47:16 +0300 Subject: [PATCH 15/17] lala --- hw6/toPostfix/toPostfix/toPostfix/main.cpp | 18 --- .../toPostfix/toPostfix/toPostfix.vcxproj | 139 ------------------ 2 files changed, 157 deletions(-) delete mode 100644 hw6/toPostfix/toPostfix/toPostfix/main.cpp delete mode 100644 hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj diff --git a/hw6/toPostfix/toPostfix/toPostfix/main.cpp b/hw6/toPostfix/toPostfix/toPostfix/main.cpp deleted file mode 100644 index 70a9b84..0000000 --- a/hw6/toPostfix/toPostfix/toPostfix/main.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include -#include "toPostfix.h" - -using namespace std; - -int main() -{ - string infix; - cout << "Input expression to convert it to postfix\n"; - cin >> infix; - string postfix; - toPostfix(infix, postfix); - cout << "Result is\n"; - cout << postfix << endl; - - return 0; -} \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj b/hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj deleted file mode 100644 index ebfd4e6..0000000 --- a/hw6/toPostfix/toPostfix/toPostfix/toPostfix.vcxproj +++ /dev/null @@ -1,139 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {326EF805-B509-486B-9522-8892D74DD3F2} - toPostfix - 10.0.17134.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - true - true - - - Console - - - - - Level3 - Disabled - true - true - - - Console - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - Console - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - Console - - - - - - - - - - - - - - - - - \ No newline at end of file From bc2cfb62cecf06fa879f8ba45083952bce8c8b4b Mon Sep 17 00:00:00 2001 From: Victoria Date: Sun, 23 Dec 2018 00:13:15 +0300 Subject: [PATCH 16/17] Changed encoding --- hw6/toPostfix/toPostfix.sln | 31 ++++ hw6/toPostfix/toPostfix/Element.cpp | 12 ++ hw6/toPostfix/toPostfix/Element.h | 11 ++ Makefile => hw6/toPostfix/toPostfix/Makefile | 0 hw6/toPostfix/toPostfix/Stack.cpp | 65 ++++++++ hw6/toPostfix/toPostfix/Stack.h | 24 +++ hw6/toPostfix/toPostfix/main.cpp | 18 +++ hw6/toPostfix/toPostfix/toPostfix.cpp | 130 ++++++++++++++++ hw6/toPostfix/toPostfix/toPostfix.h | 8 + hw6/toPostfix/toPostfix/toPostfix.vcxproj | 139 ++++++++++++++++++ .../toPostfix/toPostfix.vcxproj.filters | 42 ++++++ 11 files changed, 480 insertions(+) create mode 100644 hw6/toPostfix/toPostfix.sln create mode 100644 hw6/toPostfix/toPostfix/Element.cpp create mode 100644 hw6/toPostfix/toPostfix/Element.h rename Makefile => hw6/toPostfix/toPostfix/Makefile (100%) create mode 100644 hw6/toPostfix/toPostfix/Stack.cpp create mode 100644 hw6/toPostfix/toPostfix/Stack.h create mode 100644 hw6/toPostfix/toPostfix/main.cpp create mode 100644 hw6/toPostfix/toPostfix/toPostfix.cpp create mode 100644 hw6/toPostfix/toPostfix/toPostfix.h create mode 100644 hw6/toPostfix/toPostfix/toPostfix.vcxproj create mode 100644 hw6/toPostfix/toPostfix/toPostfix.vcxproj.filters diff --git a/hw6/toPostfix/toPostfix.sln b/hw6/toPostfix/toPostfix.sln new file mode 100644 index 0000000..5709a32 --- /dev/null +++ b/hw6/toPostfix/toPostfix.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.168 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toPostfix", "toPostfix\toPostfix.vcxproj", "{B55FBF06-8E02-4A72-BF82-4EC773EE54DC}" +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 + {B55FBF06-8E02-4A72-BF82-4EC773EE54DC}.Debug|x64.ActiveCfg = Debug|x64 + {B55FBF06-8E02-4A72-BF82-4EC773EE54DC}.Debug|x64.Build.0 = Debug|x64 + {B55FBF06-8E02-4A72-BF82-4EC773EE54DC}.Debug|x86.ActiveCfg = Debug|Win32 + {B55FBF06-8E02-4A72-BF82-4EC773EE54DC}.Debug|x86.Build.0 = Debug|Win32 + {B55FBF06-8E02-4A72-BF82-4EC773EE54DC}.Release|x64.ActiveCfg = Release|x64 + {B55FBF06-8E02-4A72-BF82-4EC773EE54DC}.Release|x64.Build.0 = Release|x64 + {B55FBF06-8E02-4A72-BF82-4EC773EE54DC}.Release|x86.ActiveCfg = Release|Win32 + {B55FBF06-8E02-4A72-BF82-4EC773EE54DC}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {809B30E6-B5A3-4CEC-81E1-43A203AF728F} + EndGlobalSection +EndGlobal diff --git a/hw6/toPostfix/toPostfix/Element.cpp b/hw6/toPostfix/toPostfix/Element.cpp new file mode 100644 index 0000000..288d2ef --- /dev/null +++ b/hw6/toPostfix/toPostfix/Element.cpp @@ -0,0 +1,12 @@ +#include "Element.h" + +Element::Element(char data) +{ + this->data = data; + this->next = nullptr; +} + +Element::~Element() +{ + this->next = nullptr; +} \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/Element.h b/hw6/toPostfix/toPostfix/Element.h new file mode 100644 index 0000000..34b4aaa --- /dev/null +++ b/hw6/toPostfix/toPostfix/Element.h @@ -0,0 +1,11 @@ +#pragma once + +struct Element +{ + Element(char data = '\0'); + + ~Element(); + + char data; + Element* next; +}; \ No newline at end of file diff --git a/Makefile b/hw6/toPostfix/toPostfix/Makefile similarity index 100% rename from Makefile rename to hw6/toPostfix/toPostfix/Makefile diff --git a/hw6/toPostfix/toPostfix/Stack.cpp b/hw6/toPostfix/toPostfix/Stack.cpp new file mode 100644 index 0000000..000c1f2 --- /dev/null +++ b/hw6/toPostfix/toPostfix/Stack.cpp @@ -0,0 +1,65 @@ +#include "Stack.h" +#include "Element.h" + +Stack::Stack() +{ + head = nullptr; +} + +Stack::~Stack() +{ + auto* temp = head; + while (!isEmpty()) + { + temp = head; + head = temp->next; + temp->next = nullptr; + delete temp; + temp = nullptr; + } +} + +void Stack::push(char data) +{ + auto* newElement = new Element(data); + if (!isEmpty()) + { + newElement->next = head; + } + head = newElement; +} + +int Stack::pop() +{ + if (!isEmpty()) + { + auto* temp = head->next; + head->next = nullptr; + delete head; + head = nullptr; + head = temp; + return 0; + } + else + { + return -1; + } +} + +char Stack::peek() +{ + if (!isEmpty()) + { + return head->data; + } + else + { + cout << "Stack is empty\n"; + return '\0'; + } +} + +bool Stack::isEmpty() +{ + return head == nullptr; +} \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/Stack.h b/hw6/toPostfix/toPostfix/Stack.h new file mode 100644 index 0000000..5cdbdd1 --- /dev/null +++ b/hw6/toPostfix/toPostfix/Stack.h @@ -0,0 +1,24 @@ +#pragma once +#include + +using namespace std; + +struct Element; + +struct Stack +{ + // + Stack(); + // + ~Stack(); + // + void push(char data); + // + int pop(); + // + char peek(); + // + bool isEmpty(); +private: + Element * head; +}; \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/main.cpp b/hw6/toPostfix/toPostfix/main.cpp new file mode 100644 index 0000000..5bdc570 --- /dev/null +++ b/hw6/toPostfix/toPostfix/main.cpp @@ -0,0 +1,18 @@ +#include +#include +#include "toPostfix.h" + +using namespace std; + +int main() +{ + string infix; + cout << "Input expression to convert it to postfix\n"; + cin >> infix; + string postfix; + toPostfix(infix, postfix); + cout << "Expression in postfix notation\n"; + cout << postfix << endl; + + return 0; +} \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix.cpp b/hw6/toPostfix/toPostfix/toPostfix.cpp new file mode 100644 index 0000000..0ffb927 --- /dev/null +++ b/hw6/toPostfix/toPostfix/toPostfix.cpp @@ -0,0 +1,130 @@ +#include "toPostfix.h" + +bool isOperator(char const symbol); +bool isRoundBracket(char const symbol); +void doIfOperator(Stack & s, string & toPostrix, int & currentIndex, char const currentSymbol); +int doIfRoundBracket(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol); +int popAllOperators(Stack & s, string & toPostfix, int & currentIndex); +bool isPlusOrMinus(char const symbol); +bool isMultOrDiv(char const symbol); + +int toPostfix(string const & infix, string & toPostfix) +{ + Stack s; + int currentIndex = 0; + for (int i = 0; i < (int)infix.size(); ++i) + { + if (!isOperator(infix[i]) && !isRoundBracket(infix[i])) + { + toPostfix += infix[i]; + ++currentIndex; + } + else + { + if (isOperator(infix[i])) + { + doIfOperator(s, toPostfix, currentIndex, infix[i]); + } + else + { + if (doIfRoundBracket(s, toPostfix, currentIndex, infix[i]) == -1) + { + cout << "Infix expression is incorrect" << endl; + return -1; + } + } + } + } + while (!s.isEmpty()) + { + if (popAllOperators(s, toPostfix, currentIndex) == -1) + { + return -1; + } + } + return 0; +} + +bool isOperator(char const symbol) +{ + return (symbol == '+' || symbol == '-' || symbol == '*' || symbol == '/'); +} + +bool isRoundBracket(char const symbol) +{ + return (symbol == '(' || symbol == ')'); +} + +void doIfOperator(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol) +{ + if (s.isEmpty()) + { + s.push(currentSymbol); + } + else + { + if (isMultOrDiv(currentSymbol) && isPlusOrMinus(s.peek()) || s.peek() == ')') + { + s.push(currentSymbol); + } + else if (s.peek() == '(') + { + s.push(currentSymbol); + } + else + { + // òåêóùèé ñèìâîë óìíîæ èëè äåë, ïîñëåäíèé ýëåìåíò íà ñòåêå - óìíîæèòü èëè äåëèòü + // òåêóùèé ýëåìåíò ïëþñ èëè ìèíóñ, ïîñëåäíèé ýëåìåíò íà ñòåêå - îïåðàòîð + toPostfix += s.peek(); + ++currentIndex; + s.pop(); + s.push(currentSymbol); + } + } +} + +int doIfRoundBracket(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol) +{ + if (currentSymbol == ')' && s.isEmpty()) + { + return -1; + } + else if (currentSymbol == ')' && isOperator(s.peek())) + { + toPostfix += s.peek(); + ++currentIndex; + s.pop(); + if (s.peek() == '(') + { + s.pop(); + } + } + else + { + // åñëè ñêîáêà êðóãëàÿ, òî ïðîñòî êëàäåì åå â ñòåê + s.push(currentSymbol); + } + return 0; +} + +int popAllOperators(Stack & s, string & toPostfix, int & currentIndex) +{ + if (isRoundBracket(s.peek())) + { + return -1; + } + toPostfix += s.peek(); + ++currentIndex; + s.pop(); + return 0; +} + +bool isPlusOrMinus(char const symbol) +{ + return (symbol == '+' || symbol == '-'); +} + +bool isMultOrDiv(char const symbol) +{ + return (symbol == '*' || symbol == '/'); +} \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix.h b/hw6/toPostfix/toPostfix/toPostfix.h new file mode 100644 index 0000000..ceeb636 --- /dev/null +++ b/hw6/toPostfix/toPostfix/toPostfix.h @@ -0,0 +1,8 @@ +#pragma once +#include +#include +#include "Stack.h" + +using namespace std; + +int toPostfix(string const & infix, string & toPostfix); \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix.vcxproj b/hw6/toPostfix/toPostfix/toPostfix.vcxproj new file mode 100644 index 0000000..46df7fd --- /dev/null +++ b/hw6/toPostfix/toPostfix/toPostfix.vcxproj @@ -0,0 +1,139 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {B55FBF06-8E02-4A72-BF82-4EC773EE54DC} + toPostfix + 10.0.17763.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + true + + + Console + + + + + Level3 + Disabled + true + true + + + Console + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + Console + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + Console + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/toPostfix.vcxproj.filters b/hw6/toPostfix/toPostfix/toPostfix.vcxproj.filters new file mode 100644 index 0000000..2ecb9ba --- /dev/null +++ b/hw6/toPostfix/toPostfix/toPostfix.vcxproj.filters @@ -0,0 +1,42 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;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 25a1cd147b8d77a167209a327181b504d77815cd Mon Sep 17 00:00:00 2001 From: Victoria Date: Sun, 23 Dec 2018 22:04:29 +0300 Subject: [PATCH 17/17] now it works --- .../from infix to postfix.sln | 31 ----- .../from infix to postfix/Element.cpp | 13 -- .../from infix to postfix/Element.h | 9 -- .../Infix to postfix.cpp | 130 ----------------- .../from infix to postfix/Infix to postfix.h | 8 -- .../from infix to postfix/Makefile | 14 -- .../from infix to postfix/Stack.cpp | 65 --------- .../from infix to postfix/Stack.h | 28 ---- .../from infix to postfix.vcxproj | 131 ------------------ .../from infix to postfix.vcxproj.filters | 42 ------ .../from infix to postfix/main.cpp | 18 --- hw6/toPostfix/toPostfix/Makefile | 9 +- hw6/toPostfix/toPostfix/inConsole.PNG | Bin 0 -> 26759 bytes ...0\257\321\200\320\273\321\213\320\272.lnk" | Bin 0 -> 1087 bytes 14 files changed, 7 insertions(+), 491 deletions(-) delete mode 100644 hw6/from infix to postfix/from infix to postfix.sln delete mode 100644 hw6/from infix to postfix/from infix to postfix/Element.cpp delete mode 100644 hw6/from infix to postfix/from infix to postfix/Element.h delete mode 100644 hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp delete mode 100644 hw6/from infix to postfix/from infix to postfix/Infix to postfix.h delete mode 100644 hw6/from infix to postfix/from infix to postfix/Makefile delete mode 100644 hw6/from infix to postfix/from infix to postfix/Stack.cpp delete mode 100644 hw6/from infix to postfix/from infix to postfix/Stack.h delete mode 100644 hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj delete mode 100644 hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters delete mode 100644 hw6/from infix to postfix/from infix to postfix/main.cpp create mode 100644 hw6/toPostfix/toPostfix/inConsole.PNG create mode 100644 "hw6/toPostfix/toPostfix/toPostfix - \320\257\321\200\320\273\321\213\320\272.lnk" diff --git a/hw6/from infix to postfix/from infix to postfix.sln b/hw6/from infix to postfix/from infix to postfix.sln deleted file mode 100644 index 15c917f..0000000 --- a/hw6/from infix to postfix/from infix to postfix.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "from infix to postfix", "from infix to postfix\from infix to postfix.vcxproj", "{54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}" -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 - {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Debug|x64.ActiveCfg = Debug|x64 - {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Debug|x64.Build.0 = Debug|x64 - {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Debug|x86.ActiveCfg = Debug|Win32 - {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Debug|x86.Build.0 = Debug|Win32 - {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Release|x64.ActiveCfg = Release|x64 - {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Release|x64.Build.0 = Release|x64 - {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Release|x86.ActiveCfg = Release|Win32 - {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {05DC8ABC-44E6-489E-859E-8BB93557CE7C} - EndGlobalSection -EndGlobal diff --git a/hw6/from infix to postfix/from infix to postfix/Element.cpp b/hw6/from infix to postfix/from infix to postfix/Element.cpp deleted file mode 100644 index 8bbeb35..0000000 --- a/hw6/from infix to postfix/from infix to postfix/Element.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "Element.h" - -Element::Element(char data = '\0') -{ - this->data = data; - this->next = nullptr; -} - -Element::~Element() -{ - this->data = '\0'; - this->next = nullptr; -} \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/Element.h b/hw6/from infix to postfix/from infix to postfix/Element.h deleted file mode 100644 index f15288d..0000000 --- a/hw6/from infix to postfix/from infix to postfix/Element.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -struct Element -{ - Element(char data); - ~Element(); - char data; - Element* next; -}; \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp deleted file mode 100644 index 4425ba4..0000000 --- a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "Infix to postfix.h" - -bool isOperator(char const symbol); -bool isRoundBracket(char const symbol); -void doIfOperator(Stack & s, string & toPostrix, int & currentIndex, char const currentSymbol); -int doIfRoundBracket(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol); -int popAllOperators(Stack & s, string & toPostfix, int & currentIndex); -bool isPlusOrMinus(char const symbol); -bool isMultOrDiv(char const symbol); - -int infixToPostfix(string const & infix, string & toPostfix) -{ - Stack s; - int currentIndex = 0; - for (int i = 0; i < (int)infix.size(); ++i) - { - if (!isOperator(infix[i]) && !isRoundBracket(infix[i])) - { - toPostfix += infix[i]; - ++currentIndex; - } - else - { - if (isOperator(infix[i])) - { - doIfOperator(s, toPostfix, currentIndex, infix[i]); - } - else - { - if (doIfRoundBracket(s, toPostfix, currentIndex, infix[i]) == -1) - { - cout << "Infix expression is incorrect" << endl; - return -1; - } - } - } - } - while (!s.isEmpty()) - { - if (popAllOperators(s, toPostfix, currentIndex) == -1) - { - return -1; - } - } - return 0; -} - -bool isOperator(char const symbol) -{ - return (symbol == '+' || symbol == '-' || symbol == '*' || symbol == '/'); -} - -bool isRoundBracket(char const symbol) -{ - return (symbol == '(' || symbol == ')'); -} - -void doIfOperator(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol) -{ - if (s.isEmpty()) - { - s.push(currentSymbol); - } - else - { - if (isMultOrDiv(currentSymbol) && isPlusOrMinus(s.peek()) || s.peek() == ')') - { - s.push(currentSymbol); - } - else if (s.peek() == '(') - { - s.push(currentSymbol); - } - else - { - // , - - // , - - toPostfix += s.peek(); - ++currentIndex; - s.pop(); - s.push(currentSymbol); - } - } -} - -int doIfRoundBracket(Stack & s, string & toPostfix, int & currentIndex, char const currentSymbol) -{ - if (currentSymbol == ')' && s.isEmpty()) - { - return -1; - } - else if (currentSymbol == ')' && isOperator(s.peek())) - { - toPostfix += s.peek(); - ++currentIndex; - s.pop(); - if (s.peek() == '(') - { - s.pop(); - } - } - else - { - // , - s.push(currentSymbol); - } - return 0; -} - -int popAllOperators(Stack & s, string & toPostfix, int & currentIndex) -{ - if (isRoundBracket(s.peek())) - { - return -1; - } - toPostfix += s.peek(); - ++currentIndex; - s.pop(); - return 0; -} - -bool isPlusOrMinus(char const symbol) -{ - return (symbol == '+' || symbol == '-'); -} - -bool isMultOrDiv(char const symbol) -{ - return (symbol == '*' || symbol == '/'); -} \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h b/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h deleted file mode 100644 index ba84706..0000000 --- a/hw6/from infix to postfix/from infix to postfix/Infix to postfix.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include -#include -#include "Stack.h" - -using namespace std; - -int infixToPostfix(string const & infix, string & toPostfix); \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/Makefile b/hw6/from infix to postfix/from infix to postfix/Makefile deleted file mode 100644 index 97ee117..0000000 --- a/hw6/from infix to postfix/from infix to postfix/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -from_infix_to_postfix: from_infix_to_postfix Element.o Infix_to_postfix.o Stack.o main.o - g++ -o from_infix_to_postfix Element.o Infix_to_postfix.o Stack.o main.o - -Infix_to_postfix.o: Infix to postfix.cpp Infix to postfix.h - g++ -c Infix to postfix.cpp -Element.o: Element.cpp Element.h - g++ -c Element.cpp -main.o: main.cpp Infix to postfix.h - g++ -c main.cpp -Stack.o: Stack.cpp Stack.h Element.h - g++ -c Stack.cpp - -clean: - del *.o \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/Stack.cpp b/hw6/from infix to postfix/from infix to postfix/Stack.cpp deleted file mode 100644 index 000c1f2..0000000 --- a/hw6/from infix to postfix/from infix to postfix/Stack.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "Stack.h" -#include "Element.h" - -Stack::Stack() -{ - head = nullptr; -} - -Stack::~Stack() -{ - auto* temp = head; - while (!isEmpty()) - { - temp = head; - head = temp->next; - temp->next = nullptr; - delete temp; - temp = nullptr; - } -} - -void Stack::push(char data) -{ - auto* newElement = new Element(data); - if (!isEmpty()) - { - newElement->next = head; - } - head = newElement; -} - -int Stack::pop() -{ - if (!isEmpty()) - { - auto* temp = head->next; - head->next = nullptr; - delete head; - head = nullptr; - head = temp; - return 0; - } - else - { - return -1; - } -} - -char Stack::peek() -{ - if (!isEmpty()) - { - return head->data; - } - else - { - cout << "Stack is empty\n"; - return '\0'; - } -} - -bool Stack::isEmpty() -{ - return head == nullptr; -} \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/Stack.h b/hw6/from infix to postfix/from infix to postfix/Stack.h deleted file mode 100644 index 9a208c5..0000000 --- a/hw6/from infix to postfix/from infix to postfix/Stack.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include - -using namespace std; - -struct Element; - -struct Stack -{ - // - Stack(); - // - ~Stack(); - // - - // - - // - void push(char data); - // - int pop(); - // - char peek(); - // - bool isEmpty(); -private: - Element * head; -}; \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj b/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj deleted file mode 100644 index 15c763d..0000000 --- a/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj +++ /dev/null @@ -1,131 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {54D5BC53-220D-4FE3-BB72-1FF3E987C3AD} - frominfixtopostfix - 10.0.17134.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters b/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters deleted file mode 100644 index 25e11fb..0000000 --- a/hw6/from infix to postfix/from infix to postfix/from infix to postfix.vcxproj.filters +++ /dev/null @@ -1,42 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;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/hw6/from infix to postfix/from infix to postfix/main.cpp b/hw6/from infix to postfix/from infix to postfix/main.cpp deleted file mode 100644 index 6a7cee3..0000000 --- a/hw6/from infix to postfix/from infix to postfix/main.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include -#include "Infix to postfix.h" - -using namespace std; - -int main() -{ - string infix; - cout << "Input infix expression\n"; - cin >> infix; - string postfix; - infixToPostfix(infix, postfix); - cout << postfix << endl; - - system("pause"); - return 0; -} \ No newline at end of file diff --git a/hw6/toPostfix/toPostfix/Makefile b/hw6/toPostfix/toPostfix/Makefile index 7bc2955..4a4c617 100644 --- a/hw6/toPostfix/toPostfix/Makefile +++ b/hw6/toPostfix/toPostfix/Makefile @@ -1,12 +1,17 @@ -toPostfix: Element.o toPostfix.o Stack.o main.o - g++ -o Element.o toPostfix.o Stack.o main.o +all: toPostfix + +toPostfix: Element.o toPostfix.o Stack.o main.o + g++ Element.o toPostfix.o Stack.o main.o -o toPostfix toPostfix.o: toPostfix.cpp toPostfix.h g++ -c toPostfix.cpp + Element.o: Element.cpp Element.h g++ -c Element.cpp + main.o: main.cpp toPostfix.h g++ -c main.cpp + Stack.o: Stack.cpp Stack.h Element.h g++ -c Stack.cpp diff --git a/hw6/toPostfix/toPostfix/inConsole.PNG b/hw6/toPostfix/toPostfix/inConsole.PNG new file mode 100644 index 0000000000000000000000000000000000000000..20bcd445c4285b20383420d5c803bdc5e41c92a0 GIT binary patch literal 26759 zcmdqJc~p|?+dt~IEX#4%-fB+hE~{M*S>}YIsby(q?FKEU%yLK(4HXrUtQ^XeX3H^c zu*oSEL{v&k8WbE#6ht%(G({v71O$GMwfFb^{@(Sz>-^qx);jB~^G7}L4EJ+C_ceX4 z>-yYXK6t=WW3~QjB_$<|eS1CrQc_a!P*PHssjdLdu#96)1BYMWe|fqoRg(=Tfgj5w zcKPg5QmVtKErzN9zgNZWJq}k=(lJ~5^UJ=!Hq0t1MH=q&*mWd1m@A_^xAA3eN_H+P z4@$5w2p6_aL91qt@;ojD|M~U%&_d80=wL;TZP(Qc>XMT_TmQJQcPqCdes%avri)I; zHr7P3@e%!0{-{fjy}K3CFZ^`)={@1QUmnbO@*gMudUj<^&X#|><=LPA`{ly_H!nZUR_;|W(fkm| z?SGr1m-7ST)gB6jVglsyU!0Fn2oztrXemaH!A+rO(SLr&DBh#vq&Rt{Vv4T#f)-%v z(Q=%k1U-nY`nR?Ci}ECUSudK$RJbtZOvR!iVBAH5UPQ+#SZI+VPRdl2$!msO6afmd z!pr2@e>|BUBYPXN__iY*nF(K9SeQ^?YubfOXIrh66^e1DR0IPl#ER$d(2_D42dAK; z7eGw;1I4)Fo=o5(At^jeo_z`!D1)JGV8Lj~bK;Dm`k%37#Y%-~Uv^XEakbiO#k;D*j6Hi({*hVIXiATh^@dptXv}W zLwn^@qeV_*5f9$>1wE0NhJqO__6WUQk1ZPpqjh_^HOJ{%QFjgi72 z-iS$*3(62HdaR5;##n^-{$om?V9&0FI{$^45mh(-mTKuNFPS&Xm|)5XXpvA${@Nun z(}hGjJjN#~L<%_3{sGX%J;SiY1N%Q(dH0mF_{)<@W zmNmcExtR&3IxQ9}WJl+py3WBC^N8_MI$8?D?V50rMkrqVE;lq*qh!wRkUPW*5OOjz z%IbXaylVo7k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