I know the big-O complexity of this algorithm is O(n^2), but I cannot understand why.
O(n^2)
int sum = 0; int i = 1; j = n * n; while (i++ < j--) s
Your algorithm is equivalent to
while (i += 2 < n*n) ...
which is O(n^2/2) which is the same to O(n^2) because big O complexity does not care about constants.
O(n^2/2)