From 97e81ebfcfc77fbf9a76b889feac765801a188fa Mon Sep 17 00:00:00 2001 From: Nataliia Brown Date: Thu, 15 Feb 2024 15:10:12 -0800 Subject: compiles and is correct --- In class 11/In class 11/main.cpp | 50 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'In class 11') diff --git a/In class 11/In class 11/main.cpp b/In class 11/In class 11/main.cpp index 7bdbc4a..d88e3e1 100644 --- a/In class 11/In class 11/main.cpp +++ b/In class 11/In class 11/main.cpp @@ -1,4 +1,52 @@ // Name: Nataliia Brown // Date: 2/15/24 // Class: CST 116 -// Assignment: In-Class Exercise 11 \ No newline at end of file +// Assignment: In-Class Exercise 11 + +#include +#include + +using std::cout; +using std::cin; +using std::endl; + +const size_t ROW = 3; +const size_t COLUMN = 3; + +void Print2DArray(int(&matrix)[ROW][COLUMN]) +{ + for (auto i = 0u; i < ROW; ++i) + { + for (auto j = 0u; j < COLUMN; ++j) + { + cout << matrix[i][j] << " "; + } + cout << endl; + } + cout << endl; + +} + + +int main() { + + int matrix[ROW][COLUMN]{ + {0,0,0}, + {0,0,0}, + {0,0,0} + }; + int x = 0; + + for (auto i = 0u; i < ROW; ++i) + { + for (auto j = 0u; j < COLUMN; ++j) + { + ++x; + matrix[i][j] = x; + } + } + + Print2DArray(matrix); + return 0; +} + -- cgit v1.2.3