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
|
#include <iostream>
#include <matrix.h>
#include <cmath>
using namespace std;
int main()
{
int r = 4;
int c = 4;
matrix matrixA(r,c);
matrix matrixB(r,c);
matrix matrixC(r,c);
for (int i=0; i<r; i++){
for (int j=0; j<c; j++){
matrixA.setValue(i,j,1);
matrixB.setValue(i,j,2);
//matrixC.setValue(i,j,5);
}
}
cout << "matrixA" << endl;
for (int i=0; i<r; i++){
for (int j=0; j<c; j++){
cout << matrixA.getValue(i,j) << "\t";
}
cout << endl;
}
cout << endl;
cout << "matrixB" << endl;
for (int i=0; i<r; i++){
for (int j=0; j<c; j++){
cout << matrixB.getValue(i,j) << "\t";
}
cout << endl;
}
cout << endl;
cout << "matrixC before addition" << endl;
for (int i=0; i<r; i++){
for (int j=0; j<c; j++){
cout << matrixC.getValue(i,j) << "\t";
}
cout << endl;
}
cout << endl;
matrixC = matrixA; // + matrixB;
cout << "matrixC after addition" << endl;
for (int i=0; i<r; i++){
for (int j=0; j<c; j++){
cout << matrixC.getValue(i,j) << "\t";
}
cout << endl;
}
cout << endl;
}
|