aboutsummaryrefslogtreecommitdiff
path: root/CST116F2021-Proj3/Functions.cpp
blob: 4a04137035e3060d3d37bbd1e09bf7822d04aaad (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
#include "Header.h"

//function definitions
void getNewMatrices(float Matrix1[3][3], float Matrix2[3][3])
{
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cout << "Value " << (i*3) + (j+1) << " of Matrix 1: ";
			cin >> Matrix1[i][j];
		}
	}

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cout << "Value " << (i * 3) + (j + 1) << " of Matrix 2: ";
			cin >> Matrix2[i][j];
		}
	}
}

void addMatrices(float Matrix1[3][3], float Matrix2[3][3])
{
	float displayMatrix[3][3];
	char upperCornerL = 218, upperCornerR = 191, lowerCornerL = 192, lowerCornerR = 217;

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			displayMatrix[i][j] = Matrix1[i][j] + Matrix2[i][j];
		}
	}

	cout << upperCornerL << setw(21) << upperCornerR
		<< endl;
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cout << setw(6) <<  displayMatrix[i][j];
		}
		cout << endl;
	}
	cout << lowerCornerL << setw(21) << lowerCornerR;
}