1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include <iostream>
using namespace std;
int main()
{
int array1[4][4]={{0,1,2,3},{9,3,4,2},{3,2,1,8},{3,1,4,7}};
int array2[4][4]={{4,5,6,7},{4,4,2,3},{1,2,5,4},{9,4,2,4}};
int array3[4][4]={{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}; // save the product
// array3 = array1 * array2
for (int j=0; j<4; j++){
for (int i=0; i<4; i++){
array3[i][j] = array1[i][j] * array2[i][j];
cout << array3[i][j] << " = " << array1[i][j] << " * " << array2[i][j] << endl;
cout << endl;
}
}
return 0;
}
|