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
|
Use following main() function.
4. main() function
. . . . // insert necessary inludings here (e.g., library)
#define SIZE_2D 5
#define SIZE_R 50000
. . . . // insert necessary definitions here
void printMtrx(const int mX[], int size);
void mtrxAdd(double mA[][SIZE_2D], double mB[][SIZE_2D], double mC[][SIZE_2D], int size_n);
void mtrxSub(double mA[][SIZE_2D], double mB[][SIZE_2D], double mD[][SIZE_2D], int size_n);
void mtrxMul(double mA[][SIZE_2D], double mB[][SIZE_2D], double mE[][SIZE_2D], int size_n);
void main()
{
double mA[SIZE_2D][SIZE_2D] =
{ {1.0, 2.0, 3.0, 4.0, 5.0},
{2.0, 3.0, 4.0, 5.0, 1.0},
{3.0, 2.0, 5.0, 3.0, 2.0},
{4.0, 3.0, 2.0, 7.0, 2.0},
{5.0, 4.0, 3.0, 2.0, 9.0},
};
double mB[SIZE_2D][SIZE_2D] =
{ {1.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 1.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 1.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 1.0, 0.0},
{0.0, 0.0, 0.0, 0.0, 1.0},
};
double mC[SIZE_2D][SIZE_2D], mD[SIZE_2D][SIZE_2D], mE[SIZE_2D][SIZE_2D];
int rn[SIZE_R];
int max, min;
double avg, var, st_dev;
cout << "Mtrx_A:" << endl;
printMtrx(mA, SIZE_2D);
cout << "Mtrx_B:" << endl;
printMtrx(mB, SIZE_2D);
mtrxAdd(mA, mB, mC, SIZE_2D);
cout << "Mtrx_C = Mtrx_A + Mtrx_B:" << endl;
printMtrx(mC, SIZE_2D);
mtrxSub(mA, mB, mD, SIZE_2D);
cout << "Mtrx_D = Mtrx_A - Mtrx_B:" << endl;
printMtrx(mD, SIZE_2D);
mtrxMul(mA, mB, mE, SIZE_2D);
cout << "Mtrx_E = Mtrx_A x Mtrx_B:" << endl;
printMtrx(mE, SIZE_2D);
|