1) How would you do this if you were doing it by hand? Probably something like this:
- scale B by 5.
- subtract that matrix from A
2) what do you mean? It looks to me like you need to define subtractMatrices and scalarMultiply, but otherwise I don't understand what you need to define.
3) You do need to do the extra calls in main() to get the A-5B result.
4) You should use [code] tags when you post so we can read your code easily.
PS - it's int main() not void main()
Infarction
Posting Virtuoso
1,580 posts since May 2006
Reputation Points: 683
Solved Threads: 53
And there's some animal screaming bloody murder out my window at the moment too, but without anymore information about the problem I'm just as helpless in either case. Please indicate what the problem is, not just that you have one.
Also, please enclose your code in code tags---read the FAQ at the top of the board if you don't know how to do so.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
Shall I go through with the standard procedure?
Don't use void main . It's bad for you. (Or rather, for your OS)
Did you forget a << endl; at the end of your statement? (Also missing closing brace)
cout << "Please enter matrix B:" << endl;
Matrix3X3 B = inputMatrix () ;
cout << "Matrix B:" <
printMatrix ( B );
// missing closing }
Missing semicolon:
Matrix3X3 scalarMultiply( Matrix3X3 a, float scale )
{
Matrix3X3 result;
for(int i=0;i<3; i++)
for(int j=0;j<3; j++)
result.index[j][i] = scale * a.index[j][i] // add ;
Try that, and your code should compile.
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
are scalarMultiply and subractMatrices returning anything? ;)
Infarction
Posting Virtuoso
1,580 posts since May 2006
Reputation Points: 683
Solved Threads: 53
are scalarMultiply and subractMatrices returning anything? ;)
Good point. :cheesy: Another function that has a similar state to the other 2 is inputMatrix .
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
how about return result; ?
Infarction
Posting Virtuoso
1,580 posts since May 2006
Reputation Points: 683
Solved Threads: 53