The function skips all elements in the diagonal 5739
(i != j
takes care of this), but, based on the desired output, you also wish to skip all elements in the diagonal 4902
.
To also check for the other diagonal, replace
if (i != j)
with
if (i != j && i != size-j-1)
Test.