Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- const int sizeY{ 3 };
- const int sizeX{ 4 };
- const int sizeZ{ 2 };
- int arr2d[sizeY][sizeX]{ {1,212,3,4},{15,6,7,8},{9,10,111,12} };
- // {
- // 0 1 2 3 x
- // 0 {1, 2, 3, 4},
- // 1 {5, 6, 7, 8},
- // 2 {9, 10, 11, 12}
- // y
- // };
- int arr3d[sizeY][sizeX][sizeZ]
- {
- {{1,2}, {3,4}, {5,6}, {7,8}},
- {{9,10}, {11,12}, {13,14}, {15,16}},
- {{17,18}, {19,20}, {21,22}, {23,24}}
- };
- arr3d[1][2][1]; //14
- arr3d[2][0][1]; //18
- char arr2DChar[2][3]
- {
- {'a','b','c'},
- {'d','e','f'}
- };
- int maxIdx{0};
- int max;
- //max = arr2d[0][0];
- for (int y{ 0 }; y < sizeY; ++y)
- {
- //maxIdx = 0;
- max = arr2d[y][0];
- for (int x{ 0 }; x < sizeX; ++x)
- {
- //if (arr2d[y][x] > arr2d[y][maxIdx])
- //{
- // maxIdx = x;
- //}
- if (arr2d[y][x] > max)
- {
- max = arr2d[y][x];
- }
- std::cout << arr2d[y][x] << ' ';
- }
- //std::cout << " max = " << arr2d[y][maxIdx] << '\n';
- std::cout << " max = " << max << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement