// John Bent's CS 110 Hand-out 6 // multi-dimensional arrays // // This program creates, fills and prints two // 2-D arrays. #include int main() { const int Rows = 3; const int Cols = 5; int grid [Rows][Cols]; int grid2 [Rows][Cols]; // fill grid1 for (int i = 0; i < Rows; i++) for (int j = 0; j < Cols; j++) grid[i][j] = i + j; // fill grid2 for (int i = 0; i < Rows; i++) for (int j = 0; j < Cols; j++) grid2[i][j] = j + (i * Cols); // to print for (int i = 0; i < Rows; i++) { for (int j = 0; j < Cols; j++) cout << grid[i][j] << " "; cout << endl; } cout << endl; // to print for (int i = 0; i < Rows; i++) { for (int j = 0; j < Cols; j++) { if (grid2[i][j] < 10) cout << " "; cout << grid2[i][j] << " "; } cout << endl; } // to compare??? // ???? return 0; }