From c0cc72f03f700ee705e139fb4bf95a7ce03d0b81 Mon Sep 17 00:00:00 2001 From: Oskar Date: Mon, 7 Oct 2024 19:46:27 +0200 Subject: more --- 9p1.cpp | 15 +++++++++++++++ 9p2.cpp | 16 ++++++++++++++++ 9p3.cpp | 14 ++++++++++++++ 9p4.cpp | 35 +++++++++++++++++++++++++++++++++++ 9p5.cpp | 36 ++++++++++++++++++++++++++++++++++++ 9p6.cpp | 22 ++++++++++++++++++++++ 6 files changed, 138 insertions(+) create mode 100644 9p1.cpp create mode 100644 9p2.cpp create mode 100644 9p3.cpp create mode 100644 9p4.cpp create mode 100644 9p5.cpp create mode 100644 9p6.cpp diff --git a/9p1.cpp b/9p1.cpp new file mode 100644 index 0000000..479e710 --- /dev/null +++ b/9p1.cpp @@ -0,0 +1,15 @@ + +/* + * + * 9.1 + * + * + */ + +int main () { + + // a) list + // b) Deque + // c) vector + return 0; +} diff --git a/9p2.cpp b/9p2.cpp new file mode 100644 index 0000000..3c1f01b --- /dev/null +++ b/9p2.cpp @@ -0,0 +1,16 @@ +#include +#include +#include + +/* + * + * 9.2 + * + * + */ + +int main () { + + std::list> ldq; + return 0; +} diff --git a/9p3.cpp b/9p3.cpp new file mode 100644 index 0000000..041de70 --- /dev/null +++ b/9p3.cpp @@ -0,0 +1,14 @@ + +/* + * + * 9.3 + * + * + */ + +int main () { + + // Begin points to first element, end points to one past the last element + // begin can not go past the end + return 0; +} diff --git a/9p4.cpp b/9p4.cpp new file mode 100644 index 0000000..83c52b8 --- /dev/null +++ b/9p4.cpp @@ -0,0 +1,35 @@ +#include +#include + +/* + * + * 9.4 + * + * + */ + +bool FindValue(std::vector::const_iterator CBegin, + std::vector::const_iterator CEnd, + int Value) { + + for( ; CBegin != CEnd ; ++CBegin) { + if(*CBegin == Value) { + return true; + } + } + + return false; +} + +int main () { + + int Value; + if(std::cin >> Value) {} else { return -1; } + + std::vector a = {1,4,2,545,42,6,334,24,5,224,7,6,9,32,3,63,436}; + if(FindValue(a.cbegin(), a.cend(), Value)) { + std::cout << "Value found!\n" << std::ends; + } + + return 0; +} diff --git a/9p5.cpp b/9p5.cpp new file mode 100644 index 0000000..542da8c --- /dev/null +++ b/9p5.cpp @@ -0,0 +1,36 @@ +#include +#include + +/* + * + * 9.5 + * + * + */ + +std::vector::const_iterator FindValue(std::vector::const_iterator CBegin, + std::vector::const_iterator CEnd, + int Value) { + + for( ; CBegin != CEnd ; ++CBegin) { + if(*CBegin == Value) { + return CBegin; + } + } + + return CEnd; +} + +int main () { + + int Value; + if(std::cin >> Value) {} else { return -1; } + + std::vector a = {1,4,2,545,42,6,334,24,5,224,7,6,9,32,3,63,436}; + if(FindValue(a.cbegin(), a.cend(), Value) == a.cend()) { + return 0; + } + + std::cout << "Value found!\n" << std::ends; + return 0; +} diff --git a/9p6.cpp b/9p6.cpp new file mode 100644 index 0000000..1893e03 --- /dev/null +++ b/9p6.cpp @@ -0,0 +1,22 @@ +#include +#include + +/* + * + * 9.6 + * + * + */ + +int main () { + + std::list lst1; + std::list::iterator iter1 = lst1.begin(), iter2 = lst1.end(); + while (iter1 != iter2) { + + } + + // Maybe it is a bit cheating but when compiling this code, there seems to be no '<' operators for the list container. + // Correct it by giving it the condition above + return 0; +} -- cgit v1.2.3