|
|
back to boardHint: be simple Posted by ASK 31 Mar 2010 19:13 Make a macro for "for" #define F(i,n) for(int i = 0; i < n; ++i) macros for start/process/stop of each line #define START int c0 = 0, ... #define P(x) if(x == 's'){ ... #define STOP mc0 = max(mc0, c0); ... vertical/horizontal lines are simple: F(i,n){ START; F(j,n) P(s[i][j]); STOP; } F(i,n){ START; F(j,n) P(s[j][i]); STOP; } The simplest diagonal is F(i,n) { START; F(j,i+1) P(s[ i-j ][ j ]); STOP; } with a macro for symmetry #define I(ind) n-1-(ind) the other lines simply invert some of coordinates: F(i,n) { START; F(j,i+1) P(s[I(i-j)][ j ]); STOP; } F(i,n-1){ START; F(j,i+1) P(s[ i-j ][I(j)]); STOP; } F(i,n-1){ START; F(j,i+1) P(s[I(i-j)][I(j)]); STOP; } |
|
|