This is only a minor thing, but you can simply your if statement. Instead of...


if ( (i % 2 == 0 && j % 2 == 0) || ( i % 2 == 1 && j % 2 == 1) )


...you can just write


if((i+j)%2 ==...