summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-09-09 20:25:43 +0200
committerOskar <[email protected]>2024-09-09 20:25:43 +0200
commit70878e5c5b4552def51082829032780c536dc59d (patch)
tree015253d567c12d90d6509ee052466217b3eacaa4
parentcc01160a3f0fdcb27eb931f67e85d783d0f5626d (diff)
more
-rw-r--r--6p19.cpp2
-rw-r--r--6p24.cpp1
-rw-r--r--6p25.cpp21
-rw-r--r--6p26.cpp23
-rw-r--r--6p27.cpp25
-rw-r--r--6p28.cpp13
-rw-r--r--6p29.cpp13
7 files changed, 96 insertions, 2 deletions
diff --git a/6p19.cpp b/6p19.cpp
index af813f4..d207b15 100644
--- a/6p19.cpp
+++ b/6p19.cpp
@@ -24,7 +24,7 @@ int main () {
calc(66); // legal
(d)
- sum(vec.begin(), vec.end(), 3.8); // legal
+ sum(vec.begin(), vec.end(), 3.8); // legalx
*/
return 0;
}
diff --git a/6p24.cpp b/6p24.cpp
index 23e5417..51104f3 100644
--- a/6p24.cpp
+++ b/6p24.cpp
@@ -1,4 +1,3 @@
-#include <iostream>
/*
*
diff --git a/6p25.cpp b/6p25.cpp
new file mode 100644
index 0000000..eb38b5f
--- /dev/null
+++ b/6p25.cpp
@@ -0,0 +1,21 @@
+#include <iostream>
+
+/*
+ *
+ * 6.25
+ *
+ *
+ */
+
+int main (int argc, char **argv) {
+
+ if (argc < 3 || argc > 3) {
+ return -1;
+ }
+
+ std::string arg1 = argv[1];
+ std::string arg2 = argv[2];
+ std::string concated = arg1 + arg2;
+ std::cout << concated << std::endl;
+ return 0;
+}
diff --git a/6p26.cpp b/6p26.cpp
new file mode 100644
index 0000000..8ad89da
--- /dev/null
+++ b/6p26.cpp
@@ -0,0 +1,23 @@
+#include <iostream>
+#include <iterator>
+
+/*
+ *
+ * 6.26
+ *
+ * Honestly not sure what i was meant to do for this exercise so
+ * ill just print the arguments we give the program.
+ */
+
+int main (int argc, char **argv) {
+
+ if(argc < 1) {
+ return -1;
+ }
+
+ for(size_t i = 1 ; argv[i] != 0 ; i++) {
+ std::cout << argv[i] << std::endl;
+ }
+
+ return 0;
+}
diff --git a/6p27.cpp b/6p27.cpp
new file mode 100644
index 0000000..2cc6f99
--- /dev/null
+++ b/6p27.cpp
@@ -0,0 +1,25 @@
+#include <iostream>
+
+/*
+ *
+ * 6.27
+ *
+ *
+ */
+
+void initlisttest(std::initializer_list<int> list) {
+
+ int sum = 0;
+ for(auto a : list) {
+ sum += a;
+ }
+ std::cout << sum << std::endl;
+}
+
+int main () {
+
+ initlisttest({10, 10, 10, 10, 10, 10});
+ initlisttest({10, 1});
+ initlisttest({2, 2, 2});
+ return 0;
+}
diff --git a/6p28.cpp b/6p28.cpp
new file mode 100644
index 0000000..6e312d6
--- /dev/null
+++ b/6p28.cpp
@@ -0,0 +1,13 @@
+
+/*
+ *
+ * 6.28
+ *
+ *
+ */
+
+int main () {
+
+ // Type is const string&
+ return 0;
+}
diff --git a/6p29.cpp b/6p29.cpp
new file mode 100644
index 0000000..b13b6c7
--- /dev/null
+++ b/6p29.cpp
@@ -0,0 +1,13 @@
+
+/*
+ *
+ * 6.29
+ *
+ *
+ */
+
+int main () {
+
+ // Yes because it does not copy the list.
+ return 0;
+}