Hi everyone
This should be one of our last assignments. Well, not sure, but most probably.
As the title implies, we're supposed to write a program using multi-dimensional arrays for a 6x6 matrix multiplication.
Here's what I've done. It's almost OK; except the most important part which is the final result. It's wrong.
What's the algorithm for matrix multiplication?
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream infile("MATRIX.dat");
ofstream outfile ("RESULT.dat");
int m1[6][6], m2[6][6], M[6][6];
int i=0, j=0;
for (i=0; i<6; i++)
{
for (j=0; j<6; j++)
{infile>>m1[i][j]
>>m2[i][j];
M[i][j] = m1[0][j]*m2[i][0];
cout<<M[i][j]<<" ";
} cout<<endl;
}
infile.close ();
outfile.close ();
return 0;
}
BTW, Ancient Dragon, Our tutor said, I asked you to use End Of File function. Why you invent sth different when you can't solve it? Insist on it, and solve it that way. :@
WTF!!! :'(