diff options
author | Oskar <[email protected]> | 2024-08-10 23:07:32 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-08-10 23:07:32 +0200 |
commit | 2ecf623735023e8fc2a4029e4653f0bd591e6052 (patch) | |
tree | 39ded673699098ea0c14d78101212127e2581729 | |
parent | 97df48a5d420072c1ed487b7d5306d1665e692db (diff) |
more
-rw-r--r-- | 3p23.cpp | 3 | ||||
-rw-r--r-- | 3p24.cpp | 50 | ||||
-rw-r--r-- | iterator-test-2.cpp | 29 |
3 files changed, 81 insertions, 1 deletions
@@ -26,7 +26,8 @@ int main () { int random_value = 0; vector<int> ff; - decltype(ff.size()) amount = 10; + decltype(ff.size()) amount = 0; + if(cin >> amount) {} else { return -1; } std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<> distr(1, 10000); diff --git a/3p24.cpp b/3p24.cpp new file mode 100644 index 0000000..1ae1ef2 --- /dev/null +++ b/3p24.cpp @@ -0,0 +1,50 @@ +#include <iostream> +#include <vector> +#include "sales_data.hpp" +#include "sales_item.hpp" + +/* + * + * 3.24 + * + * + */ + +using std::string; +using std::cout; +using std::cin; +using std::cerr; +using std::clog; +using std::endl; +using std::vector; +int main () { + + vector<int> VecNumbers; + int Numbers = 0; + while(cin >> Numbers) { + VecNumbers.push_back(Numbers); + } + + for(auto Iterate = VecNumbers.cbegin() ; Iterate < VecNumbers.cend() ; Iterate += 2) { + auto First = Iterate; + auto Second = Iterate + 1; + cout << *First + *Second << " "; + } + + cout << endl; + auto vnend = VecNumbers.cend()-1; + auto vnbeg = VecNumbers.cbegin(); + while(vnbeg <= vnend) { + if (vnbeg == vnend) { + cout << *vnbeg + *vnend << " "; + break; + } + + cout << *vnbeg + *vnend << " "; + --vnend; + ++vnbeg; + } + + cout << endl; + return 0; +} diff --git a/iterator-test-2.cpp b/iterator-test-2.cpp new file mode 100644 index 0000000..7b6d791 --- /dev/null +++ b/iterator-test-2.cpp @@ -0,0 +1,29 @@ +#include <iostream> +#include <vector> +#include "sales_data.hpp" +#include "sales_item.hpp" + +/* + * + * Just a little test, had to clear something up in my head + * + * + * + */ + +using std::string; +using std::cout; +using std::cin; +using std::cerr; +using std::clog; +using std::endl; +using std::vector; +int main () { + + vector<int> nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; + auto iter = nums.begin(); + iter += 10; + cout << "nums content: " << *iter << endl; + cout << "subscr content: " << nums[10] << endl;; + return 0; +} |