Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Structures and data algorithms / HomeworkExamPrep / main.cpp
diff options
context:
space:
mode:
Commit9d9bd35065ded1d78c9a07af2953e69fc8eb61d4 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-01-08 22:35:13 +0200
Committer
 Syndamia <kamen@syndamia.com>
2023-01-08 22:35:13 +0200
Files16c6371881423dae7690de56e689171e83bb68ec /Year 2/Structures and data algorithms/HomeworkExamPrep/main.cpp
uni-projects-9d9bd35065ded1d78c9a07af2953e69fc8eb61d4.tar
uni-projects-9d9bd35065ded1d78c9a07af2953e69fc8eb61d4.tar.gz
uni-projects-9d9bd35065ded1d78c9a07af2953e69fc8eb61d4.zip
Parentf3ee1a0ea95ebbd08dd3dcfe341c649d8ce4a8c1 (diff)
[SDP/HEP] Added preparation for "homework" during class
1 files changed, 59 insertions, 0 deletions
-rw-r--r--Year 2/Structures and data algorithms/HomeworkExamPrep/main.cpp59
diff --git a/Year 2/Structures and data algorithms/HomeworkExamPrep/main.cpp b/Year 2/Structures and data algorithms/HomeworkExamPrep/main.cpp
new file mode 100644
index 0000000..060e94c
--- /dev/null
+++ b/Year 2/Structures and data algorithms/HomeworkExamPrep/main.cpp
@@ -0,0 +1,59 @@
+#include <iostream>
+
+// #include "Stack/Stack_Static.hpp"
+// #include "Stack/Stack_DynamicSeq.hpp"
+#include "Stack/Stack_Dynamic.hpp"
+
+// #include "Queue/Queue_Static.hpp"
+#include "Queue/Queue_Dynamic.hpp"
+
+#include "LinkedList.hpp"
+
+int main() {
+ // Stack
+ Stack<int> nums1;
+ nums1.push(1);
+ nums1.push(2);
+ nums1.push(3);
+ for (unsigned i = 0; i < 3; i++) {
+ std::cout << nums1.top() << ", ";
+ nums1.pop();
+ }
+ nums1.push(4);
+ std::cout << nums1.top() << std::endl;
+
+ // Queue
+ Queue<int> nums2;
+ nums2.push(1);
+ nums2.push(2);
+ nums2.push(3);
+ for (unsigned i = 0; i < 3; i++) {
+ std::cout << nums2.front() << ", ";
+ nums2.pop();
+ }
+ nums2.push(4);
+ std::cout << nums2.front() << std::endl;
+
+ // Linked List
+ LinkedList<int> nums3;
+ nums3.push_front(1);
+ nums3.push_back(3);
+ nums3.push_at(1, 2);
+ for (int& i : nums3)
+ std::cout << i << ", ";
+ std::cout << std::endl;
+
+ LinkedList<int> nums4;
+ nums4.push_back(1);
+ nums4.push_back(2);
+ nums4.push_back(3);
+ nums4.push_front(5);
+ nums4.push_back(5);
+ nums4.push_at(2, 5);
+ nums4.pop_at(2);
+ nums4.pop_front();
+ nums4.pop_back();
+ for (const int& i : nums4)
+ std::cout << i << ", ";
+ std::cout << std::endl;
+}