3 ms·
The author agrees with you. In the final paragraph, the author says that they allow ++ and -- when not using the value, as such use poses no harm. Also, you ca
by amavect 7mo ago
The author agrees with you. In the final paragraph, the author says that they allow ++ and -- when not using the value, as such use poses no harm.
Also, you can use a comma with += and -=,
for (int i=0, j=n; i<j; i+=1, j-=1)
but keep in mind the decrement must usually happen before the loop body (post-increment reverses to pre-decrement).
for (int i=0, j=n; i<j; i+=1) { j-=1; ... }
for (int i=0, j=n; i<j; i++) { j--; ... }