#include <iostream>
using namespace std;

int main() {
	// a 3-D array or matrix
	int matrix[3][3][3]; // 3^3 = 27 total elements
	int count = 0;

	// we know the answer already (3):
	int sizeX = sizeof(matrix) / sizeof(matrix[0]);
	int sizeY = sizeof(matrix[0])/sizeof(matrix[0][0]);
	int sizeZ = sizeof(matrix[0][0])/sizeof(matrix[0][0][0]);

	cout << "size of the x dimension: " << sizeX << endl;
	cout << "size of the y dimension: " << sizeY << endl;
	cout << "size of the x dimension: " << sizeZ << endl;

	// Row-Major traversal in 3-D:
	cout << "Row-Major Traversal:\n";
	for(int x = 0; x < sizeX; x++){
		for(int y = 0; y < sizeY; y++){
			for(int z = 0; z < sizeZ; z++){
				// give a unique number to each cell coordinate
				matrix[x][y][z] = count;
				count++;
				// Access element: array[x][y][z]
				cout << "  Element at [" << x << "][" << y << "][" << z << "]: " << matrix[x][y][z] << endl;
			}
		}
	}

	return 0;
}
