From bec90eeec483f4fd685bb28758cdf55897bc0b3e Mon Sep 17 00:00:00 2001 From: Oskar Date: Thu, 15 Aug 2024 17:26:06 +0200 Subject: more exercises and tests --- multi-arr-test.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 multi-arr-test.cpp (limited to 'multi-arr-test.cpp') diff --git a/multi-arr-test.cpp b/multi-arr-test.cpp new file mode 100644 index 0000000..bdd5306 --- /dev/null +++ b/multi-arr-test.cpp @@ -0,0 +1,57 @@ +#include +#include +#include "sales_data.hpp" +#include "sales_item.hpp" +#include + +/* + * + * + * + * + */ + +int main () { + + constexpr size_t rowCnt = 3, colCnt = 4; + int ia[rowCnt][colCnt]; + for (size_t i = 0; i != rowCnt; ++i) { + for (size_t j = 0; j != colCnt; ++j) { + ia[i][j] = i * colCnt + j; + } + } + + for(auto &a : ia) { + for(auto b : a) { + std::cout << b << " "; + } + std::cout << std::endl; + } + + int ia2[rowCnt][colCnt]; + size_t counter = 0; + for(auto &row : ia2) { + for(auto &col : row) { + col = counter; + ++counter; + } + } + + std::cout << std::endl; + for(auto &a : ia2) { + for(auto b : a) { + std::cout << b << " "; + } + std::cout << std::endl; + } + + std::cout << std::endl; + for(auto a = std::begin(ia2) ; a != std::end(ia2) ; ++a) { + for(auto aa = std::begin(*a) ; aa != std::end(*a) ; ++aa) { + std::cout << *aa << " "; + } + std::cout << std::endl; + } + + return 0; +} -- cgit v1.2.3