From e06a1fdebe095ad46b0607297f78077fccb11db1 Mon Sep 17 00:00:00 2001 From: Oskar Date: Tue, 8 Oct 2024 23:37:52 +0200 Subject: more --- 9p11.cpp | 22 ++++++++++++++++++++++ 9p12.cpp | 15 +++++++++++++++ 9p13.cpp | 29 +++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 9p11.cpp create mode 100644 9p12.cpp create mode 100644 9p13.cpp diff --git a/9p11.cpp b/9p11.cpp new file mode 100644 index 0000000..9165a26 --- /dev/null +++ b/9p11.cpp @@ -0,0 +1,22 @@ +#include +#include + +/* + * + * 9.11 + * + * + */ + +int main () { + + std::vector v1; // empty + std::vector v2(v1); // empty + std::vector v3 = v1; // empty + std::vector v4(1); // 1 element, default initialized + std::vector v5(10,1); // 10 elements, initialized to 1 + std::vector v6{10,10,1}; // 3 elements, values 10, 10, 1 + std::vector v7 = {10, 10, 1}; // 3 elements, values 10, 10, 1 + std::vector v8(v5.begin(), v5.end()); // Same as v5 + return 0; +} diff --git a/9p12.cpp b/9p12.cpp new file mode 100644 index 0000000..fd36354 --- /dev/null +++ b/9p12.cpp @@ -0,0 +1,15 @@ +#include + +/* + * + * 9.12 + * + * + */ + +int main () { + + // constructor that takes container of same type as itself and creates a copy of the other container. + // constructor with iterators take the iterators and iterate with them to copy the values. Container types dont have to be the same, just the element types that have to be the same. + return 0; +} diff --git a/9p13.cpp b/9p13.cpp new file mode 100644 index 0000000..781f1e4 --- /dev/null +++ b/9p13.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +/* + * + * 9.13 + * + * + */ + +int main () { + + std::vector vi(25, 50); + std::list li(25, 99); + std::vector vb1(vi.cbegin(), vi.cend()); + std::vector vb2(li.cbegin(), li.cend()); + for(auto &a : vb1) { + std::cout << a << " "; + } + + std::cout << std::endl; + for(auto &a : vb2) { + std::cout << a << " "; + } + + std::cout << std::endl; + return 0; +} -- cgit v1.2.3