From 9d9bd35065ded1d78c9a07af2953e69fc8eb61d4 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 8 Jan 2023 22:35:13 +0200 Subject: [SDP/HEP] Added preparation for "homework" during class --- .../HomeworkExamPrep/main.cpp | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Year 2/Structures and data algorithms/HomeworkExamPrep/main.cpp (limited to 'Year 2/Structures and data algorithms/HomeworkExamPrep/main.cpp') 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 + +// #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 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 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 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 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; +} -- cgit v1.3.1-23-gd82d