I am writing a chess engine using an array (single dimension) in C?
#define ROW(sq) (sq >> 3)
#define COL(sq) (sq & 7)
int board[64] = {
0,1,2,3,4,5,6,7,
8,9,10,11,12,13,,14,15,
.......................
.......................
56,57,48,59,60,61,62,63
}
Now: To get the row and col of number 11 I use this:
int r = ROW(11);
int c = COL(11);
It gives:
r = 1
c = 3
Please help me to write a function so that it takes the parameter as r
and c
and gives the correct square like:
sq = fnc(r,c);
sq = fnc(1,3);
sq = 11;