I'm wondering what is the difference between these loops in 2D arrays:
for (int r = row - 1, c = column - 1; r >= 0 && c >= 0; r--, c--) {
...
}
for(int r=row-1;r>=0;r--){
for(int c=column-1;c>=0;c--){
...
}
}
for (int r = row - 1, c = column - 1; r >= 0 && c >= 0; r--, c--)
The first example is one loop that decrements both r and c every cycle, meaning that the indices r and c will draw a diagonal starting at array[row-1][column-1].

for(int r=row-1;r>=0;r--){
for(int c=column-1;c>=0;c--){
The second example calls a loop for columns for each index of row, so it will access all the indices array[r][c]

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With