diff options
author | Oskar <[email protected]> | 2024-10-07 19:46:27 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-10-07 19:46:27 +0200 |
commit | c0cc72f03f700ee705e139fb4bf95a7ce03d0b81 (patch) | |
tree | 57806857b72d0fec01d223b192ec93118504479f | |
parent | ee020f14877e5ed1708147a22133e9a413a948f1 (diff) |
more
-rw-r--r-- | 9p1.cpp | 15 | ||||
-rw-r--r-- | 9p2.cpp | 16 | ||||
-rw-r--r-- | 9p3.cpp | 14 | ||||
-rw-r--r-- | 9p4.cpp | 35 | ||||
-rw-r--r-- | 9p5.cpp | 36 | ||||
-rw-r--r-- | 9p6.cpp | 22 |
6 files changed, 138 insertions, 0 deletions
@@ -0,0 +1,15 @@ + +/* + * + * 9.1 + * + * + */ + +int main () { + + // a) list + // b) Deque + // c) vector + return 0; +} @@ -0,0 +1,16 @@ +#include <iostream> +#include <list> +#include <deque> + +/* + * + * 9.2 + * + * + */ + +int main () { + + std::list<std::deque<int>> ldq; + return 0; +} @@ -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; +} @@ -0,0 +1,35 @@ +#include <iostream> +#include <vector> + +/* + * + * 9.4 + * + * + */ + +bool FindValue(std::vector<int>::const_iterator CBegin, + std::vector<int>::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<int> 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; +} @@ -0,0 +1,36 @@ +#include <iostream> +#include <vector> + +/* + * + * 9.5 + * + * + */ + +std::vector<int>::const_iterator FindValue(std::vector<int>::const_iterator CBegin, + std::vector<int>::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<int> 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; +} @@ -0,0 +1,22 @@ +#include <iostream> +#include <list> + +/* + * + * 9.6 + * + * + */ + +int main () { + + std::list<int> lst1; + std::list<int>::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; +} |