Skip to content

Instantly share code, notes, and snippets.

@Cxarli
Created January 9, 2016 21:14
Show Gist options
  • Save Cxarli/6a01c479998efab4f491 to your computer and use it in GitHub Desktop.
Save Cxarli/6a01c479998efab4f491 to your computer and use it in GitHub Desktop.
bool win = false;
if( ! win ) {
for(int n=0; n<=6; n+=3) {
if ( grid[n] == grid[n+1] && grid[n] == grid[n+2] ) {
win = true;
break;
}
}
}
if ( ! win ) {
for(int n=0; n<=2; ++n) {
if ( grid[n] == grid[n+3] && grid[n] == grid[n+6] ) {
win = true;
break;
}
}
}
if ( ! win ) {
if ( grid[0] == grid[4] && grid[0] == grid [8] ) {
win = true;
}
}
if ( ! win ) {
if ( grid[2] == grid[4] && grid[2] == grid [6] ) {
win = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment