summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--3p23.cpp3
-rw-r--r--3p24.cpp50
-rw-r--r--iterator-test-2.cpp29
3 files changed, 81 insertions, 1 deletions
diff --git a/3p23.cpp b/3p23.cpp
index 1456495..e991180 100644
--- a/3p23.cpp
+++ b/3p23.cpp
@@ -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;
+}