Determinant
Consider a 3x3 matrix
M = | a00 a01 a02
|
a10 a11 a12
|
a20 a21 a22
|
The determinant of M can be calculated by
det(M) = a00 * a11 * a22 +
a01 * a12 * a20 +
a02 * a10 * a21
- a20 * a11 * a02
- a21 * a12 * a00
- a22 * a10 * a01.
Write a program to read the 9 entities of the matrix, and calculate its
determinant.
- Although it is possible to solve this problem without using
arrays (by using 9 variables a00, a11, a22, ...), 7 weeks later we
are going to calculate the determinant of an NxN matrix, for any
positive integer N. Therefore, it is recommended that you get
familiar with calculating the determinant using an array as early as
possible.
The program may run as follows.
Please input a 3x3 matrix to calculate its determinant --
1 5 3
2 4 7
4 6 2
Its determinant is equal to 74