summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-10-08 23:37:52 +0200
committerOskar <[email protected]>2024-10-08 23:37:52 +0200
commite06a1fdebe095ad46b0607297f78077fccb11db1 (patch)
tree2c10701caf940f22caa00f4d748b715f1bff4eb3
parent62b5afc0bdff7fe33a347ab53a83e02d9f04f97e (diff)
more
-rw-r--r--9p11.cpp22
-rw-r--r--9p12.cpp15
-rw-r--r--9p13.cpp29
3 files changed, 66 insertions, 0 deletions
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 <iostream>
+#include <vector>
+
+/*
+ *
+ * 9.11
+ *
+ *
+ */
+
+int main () {
+
+ std::vector<int> v1; // empty
+ std::vector<int> v2(v1); // empty
+ std::vector<int> v3 = v1; // empty
+ std::vector<int> v4(1); // 1 element, default initialized
+ std::vector<int> v5(10,1); // 10 elements, initialized to 1
+ std::vector<int> v6{10,10,1}; // 3 elements, values 10, 10, 1
+ std::vector<int> v7 = {10, 10, 1}; // 3 elements, values 10, 10, 1
+ std::vector<int> 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 <iostream>
+
+/*
+ *
+ * 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 <iostream>
+#include <vector>
+#include <list>
+
+/*
+ *
+ * 9.13
+ *
+ *
+ */
+
+int main () {
+
+ std::vector<int> vi(25, 50);
+ std::list<int> li(25, 99);
+ std::vector<double> vb1(vi.cbegin(), vi.cend());
+ std::vector<double> 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;
+}