why not using recursion? i'm guessing this is homework
here's a few hints:
Code:
| 3 4 5 |
| 6 7 8 |
| 9 1 2 |
there are 2 ways to determine determinates by minors
or by diagonals
Code:
| 3 4 5 3 4 |
| 6 7 8 6 7 |
| 9 1 2 9 1 |
the last two columns are repeats
try this:
assuming a matrix is int a[3][3];, and its filled like above
Code:
#define BORDER_CONSTANT 3
int t=0, u=0;
for (i=0;i<3;i++)
for (j=0;j<3;j++)
t+=a[(i+j)%BORDER_CONSTANT][i];
for (i=2;i<=0;i--)
for (j=0;j<3;j++)
u+=a[(i+j)%BORDER_CONSTANT][i];
printf("%d",t-u);
i havent tested this or anything, but try to figure it out from this