Website Summary Files Commits Branches @commit @diff @stats
path: root / Seminar02 / bonusTask01.cpp
diff options
context:
space:
mode:
Commit7eee5a78005a9a569186d2c8b4b645a818ab9bf1 (patch)
Author
 Stoycho Kyosev <skyosev@192.168.100.17>
2024-10-06 07:04:44 -0400
Committer
 Stoycho Kyosev <skyosev@192.168.100.17>
2024-10-06 07:04:44 -0400
Files84594e0af29cefa5aae76ace5f8eb81484400e31 /Seminar02/bonusTask01.cpp
Data-structures-and-algorithms-7eee5a78005a9a569186d2c8b4b645a818ab9bf1.tar
Data-structures-and-algorithms-7eee5a78005a9a569186d2c8b4b645a818ab9bf1.tar.gz
Data-structures-and-algorithms-7eee5a78005a9a569186d2c8b4b645a818ab9bf1.zip
Parent0841635826cb03c0e74cd75ec3c97c4c3b594d8b (diff)
Cleanup
1 files changed, 0 insertions, 51 deletions
-rw-r--r--Seminar02/bonusTask01.cpp51
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 <iostream>
-#include <stack>
-
-void sortStack(std::stack<int> &first)
-{
- std::stack<int> 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<int> st)
-{
- while (!st.empty())
- {
- std::cout << st.top() << " ";
- st.pop();
- }
- std::cout << std::endl;
-}
-
-int main()
-{
- std::stack<int> 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