diff options
| author | Connor McDowell <[email protected]> | 2024-02-15 14:39:15 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-15 14:39:15 -0800 |
| commit | 5995656e225258dfead40be1f05584c68b8e335c (patch) | |
| tree | 9bfcd2b8c85314440d3c2779f1554365efaf5133 | |
| parent | notes cont (diff) | |
| download | in-class-exercise-11-connormcdowell275-5995656e225258dfead40be1f05584c68b8e335c.tar.xz in-class-exercise-11-connormcdowell275-5995656e225258dfead40be1f05584c68b8e335c.zip | |
2d array created, values assigned properly, however prints 9 times
| -rw-r--r-- | Project1/program.cpp | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/Project1/program.cpp b/Project1/program.cpp index 212d73f..c7715dc 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -13,33 +13,58 @@ using std::cin; using std::cout; using std::endl; +//constexpr size_t ROW = 3; +//constexpr size_t COLUMN = 4; +// +//int matrix[3][4]{ {1,2,3,4}, {5,6,7,8}, {9,10,11,12} }; +// +//int print2DArray(int(&matrix)[ROW][COLUMN]) +//{ +// for (auto i = 0u; i < ROW; ++i) +// { +// for (auto j = 0u; j < COLUMN; ++j) +// { +// cout << matrix[i][j] << " "; +// } +// } +// return 0; +//} constexpr size_t ROW = 3; -constexpr size_t COLUMN = 4; +constexpr size_t COLUMN = 3; -int matrix[3][4]{ {1,2,3,4}, {5,6,7,8}, {9,10,11,12} }; - -int print2DArray(int(&matrix)[ROW][COLUMN]) +int matrix[ROW][COLUMN] { - for (auto i = 0u; i < ROW; ++i) + {0,0,0}, + {0,0,0}, + {0,0,0} +}; + +int printArray(int(&matrix)[ROW][COLUMN]) { + for (auto i = 0; i < ROW; ++i) { for (auto j = 0u; j < COLUMN; ++j) { - cout << matrix[i][j] << " "; + for (auto t = 1; t <= 9; ++t) + { + matrix[i][j] = t; + cout << matrix[i][j] << " "; + } + } } return 0; } - int main() { - - print2DArray(matrix); + /*print2DArray(matrix); matrix[0][0] = 10; matrix[1][0] = 50; matrix[2][0] = 90; - print2DArray(matrix); + print2DArray(matrix);*/ + + printArray(matrix); return 0; }
\ No newline at end of file |