From 97df48a5d420072c1ed487b7d5306d1665e692db Mon Sep 17 00:00:00 2001 From: Oskar Date: Fri, 9 Aug 2024 12:46:41 +0200 Subject: more exercises --- 3p23.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 3p23.cpp (limited to '3p23.cpp') 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 +#include +#include +#include +#include +#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 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; +} -- cgit v1.2.3