summaryrefslogtreecommitdiff
path: root/3p23.cpp
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-08-09 12:46:41 +0200
committerOskar <[email protected]>2024-08-09 12:46:41 +0200
commit97df48a5d420072c1ed487b7d5306d1665e692db (patch)
tree9fd129a1b108828d02cf4baa6cbeef54be371afe /3p23.cpp
parent9b931cfed1551961c8bbb93b21051104c0c4c716 (diff)
more exercises
Diffstat (limited to '3p23.cpp')
-rw-r--r--3p23.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/3p23.cpp b/3p23.cpp
new file mode 100644
index 0000000..1456495
--- /dev/null
+++ b/3p23.cpp
@@ -0,0 +1,47 @@
+#include <iostream>
+#include <vector>
+#include <ctime>
+#include <cstdlib>
+#include <random>
+#include "sales_data.hpp"
+#include "sales_item.hpp"
+
+/*
+ *
+ * 3.23
+ *
+ * I added a random number generator with some help from the internet.
+ * That way i could have some random numbers which i think makes the
+ * exercise a little more interesting :)
+ */
+
+using std::string;
+using std::cout;
+using std::cin;
+using std::cerr;
+using std::clog;
+using std::endl;
+using std::vector;
+int main () {
+
+ int random_value = 0;
+ vector<int> ff;
+ decltype(ff.size()) amount = 10;
+ std::random_device rd;
+ std::mt19937 gen(rd());
+ std::uniform_int_distribution<> distr(1, 10000);
+ for(decltype(ff.size()) i = 0 ; i != amount; i++) {
+ random_value = distr(gen);
+ ff.push_back(random_value);
+ cout << ff[i] << "\n";
+ }
+
+ cout << endl;
+ for(auto ffit = ff.begin() ; ffit != ff.end() ; ffit++) {
+ *ffit *= 2;
+ cout << *ffit << "\n";
+ }
+
+ cout << endl;
+ return 0;
+}