0
Why
the question is if I type 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 i want it out 0 0 0 0 0 0 0 6 0 0 0 6 1 6 0 0 0 6 0 0 0 0 0 0 0 But now it out 0 0 0 0 0 0 0 0 0 0 0 0 1 6 0 0 0 6 0 0 0 0 0 0 0 I don't know why.'-' https://code.sololearn.com/c5AibA67q8hK/?ref=app
1 Answer
+ 4
Your code is hard to read. Please do composition for it.
Anyway, your code behaves like that because num[i][j] is not 1, leading your condition fail.
Top 6 for example, it's 0 originally. So the condition failed.
Then why the right and below are changed you may ask. It's because there is once the condition is true before them, num[2][2]. It's 1 and the numbers near it are 0. Your code in if statement is executed after it.
Your pattern does change within this condition, but it changes ONLY after num[2][2]. Those before are not changed yet and they're already printed out.
If you print num again with another nested loops, you will get your desired output.



