Answers for "c++ multidimensional arrays"

C++
-6

multidimensional array c++

int MyArray[2][3] = { {2, 3, 4}, {12, 13, 14} };

	//visualize
	//2, 3, 4
	//12, 13, 14

	std::cout << MyArray[0][2] << endl; // 4
	std::cout << MyArray[1][1] << endl; // 13

//First square bracket means how many rows you want in your array
//Second squire bracket is for how many qulam you want in your array
Posted by: Guest on April-24-2021
0

get elements of 2d array c++

void printMatrix(array<array<int, COLS>, ROWS> matrix){
for (auto row : matrix){
//auto infers that row is of type array<int, COLS>
for (auto element : row){
cout << element << ' ';
}
cout << endl;
}
Posted by: Guest on May-25-2020

Browse Popular Code Answers by Language