I want to make a function that formats a matrix that's passed like this:
1 2 3 6
4 5 6 15
7 8 9 24
12 15 18 45
Into a matrix like this:
1 2 3 | 6
4 5 6 | 15
7 8 9 | 24
=============
12 15 18 | 45
I somewhat got the part with vertical bars, but I have no idea how to do the equals part, here's my take on vertical bar:
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (j == n - 2)
printf("%d | ", mat[i][j]);
else if (j == n - 1)
printf("%d\n", mat[i][j]);
else if (i == n - 1)
printf("%d ", mat[i][j]);
else printf("%d ", mat[i][j]);
Printing === before the last row just ends up like this:
1 2 3 | 6
4 5 6 | 15
7 8 9 | 24
===
12 ===
15 18 | 45
I tried everything, but it failed miserably, any suggestions?
