Here is the problem:
I have to code a program to solve an array. The number in the array that is not -1 are given, so I cannot change them.
N1 N2 N3
2 4 -1
1 -1 1
-1 8 -1
rowsum: 8, 9, 16
columnsum: 8 9 16
Firstly, what I did is search row1 for any -1 because by having only one -1 in the row, it means that is easily solvable. If 1x-1, Then I replace it with: row1sum-(row1N1+row1N2+row1N3).
Then I move on to the next row, checking if there is only 1x-1.
Then since row3 has 2 zeroes, I will not be able to work on that. So I skip it and check columnN1. If it only has 1x-1, then: columnN1 - (row1N1+row2N2+row3N3). Then column2, then column3.
My program worked with that problem but it doesn't with this:
n1 n2 n3
5 -1 -1
-1 7 -1
8 -1 0
rowsum: 14 19 16
columnsum: 22 15 7
Why doesn't my logic works? and if you have any suggestion on how to make this more efficient, I will gladly look into it
PS. It's my first month learning C, so I don't really have an advance knowledge.
PPS. I convert -1 to 0 first before adding.