From 7eee5a78005a9a569186d2c8b4b645a818ab9bf1 Mon Sep 17 00:00:00 2001 From: Stoycho Kyosev Date: Sun, 6 Oct 2024 07:04:44 -0400 Subject: Cleanup --- Seminar02/bonusTask01.cpp | 51 ----------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 Seminar02/bonusTask01.cpp (limited to 'Seminar02/bonusTask01.cpp') diff --git a/Seminar02/bonusTask01.cpp b/Seminar02/bonusTask01.cpp deleted file mode 100644 index 6e41016..0000000 --- a/Seminar02/bonusTask01.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include - -void sortStack(std::stack &first) -{ - std::stack second; - int currentElement = 0; - while (!first.empty()) - { - currentElement = first.top(); - first.pop(); - - while (!second.empty() && second.top() > currentElement) - { - first.push(second.top()); - second.pop(); - } - second.push(currentElement); - } - - while (!second.empty()) - { - first.push(second.top()); - second.pop(); - } -} - -void stackPrint(std::stack st) -{ - while (!st.empty()) - { - std::cout << st.top() << " "; - st.pop(); - } - std::cout << std::endl; -} - -int main() -{ - std::stack st; - st.push(8); - st.push(2); - st.push(4); - st.push(1); - st.push(5); - st.push(3); - - stackPrint(st); - sortStack(st); - stackPrint(st); -} \ No newline at end of file -- cgit v1.3.1-26-gb76a