diff options
author | Oskar <[email protected]> | 2024-09-09 20:25:43 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-09-09 20:25:43 +0200 |
commit | 70878e5c5b4552def51082829032780c536dc59d (patch) | |
tree | 015253d567c12d90d6509ee052466217b3eacaa4 | |
parent | cc01160a3f0fdcb27eb931f67e85d783d0f5626d (diff) |
more
-rw-r--r-- | 6p19.cpp | 2 | ||||
-rw-r--r-- | 6p24.cpp | 1 | ||||
-rw-r--r-- | 6p25.cpp | 21 | ||||
-rw-r--r-- | 6p26.cpp | 23 | ||||
-rw-r--r-- | 6p27.cpp | 25 | ||||
-rw-r--r-- | 6p28.cpp | 13 | ||||
-rw-r--r-- | 6p29.cpp | 13 |
7 files changed, 96 insertions, 2 deletions
@@ -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; } @@ -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; +} |