1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include <iostream>
#include <array>
using namespace std;
const size_t rows = 2;
const size_t columns = 3;
void printArray(const array< array < int, columns >, rows> &);
int main()
{
array< array< int, columns >, rows > array1 = {1,2,3,4,5,6};
array< array< int, columns >, rows > array2 = {1,2,3,4,5};
cout << "Values in array1 by row are:" << endl;
printArray(array1);
cout << "\nValues in array2 by row are:" << endl;
printArray(array2);
}
void printArray(const array< array< int, columns >, rows> & a)
{
for (auto const &row : a)
{
for (auto const &element : row)
cout << element << ' ';
cout << endl;
}
}
|