aboutsummaryrefslogtreecommitdiff
path: root/Project1/program.cpp
blob: c8464825c1870a7d20ef7bbf8cead3eb2eeef4d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Name: Connor McDowell
// date: 2/12/2024
// class: CST116
// reason: inclass exercise 11, 2d arrays

#include <iostream>
#include <ostream>

/*#define ROW 3
#define COLUMN */

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 = 3;

int matrix[ROW][COLUMN]
{
	{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)
		{
			//if (i <= 9, j <= 9)
			//{
			//	int t = 0;
			//	t + 1;
			//	matrix[i][j] = t;
			//	cout << matrix[i][j] << " ";
			//}
			//int t = 1;
			//++t;
			//matrix[i][j] = t;
			//cout << matrix[i][j] << " ";
			matrix[i][j] = i * COLUMN + j + 1;
			cout << matrix[i][j] << " ";
		}
		cout << endl;
	}
	
	return 0;
}
int main()
{
	/*print2DArray(matrix);

	matrix[0][0] = 10;
	matrix[1][0] = 50;
	matrix[2][0] = 90;

	print2DArray(matrix);*/

	printArray(matrix);

	return 0;
}