// Returns the status of the board. Either X has won, O has won, the game
// is unfinished or it's a cats game.
int status(char board[][3]) {

    // X wins!
    if (checkrows(board,'X') || checkcols(board,'X') || checkdiag(board,'X'))
        return WINX;
    
    // O wins!
    if (checkrows(board,'O') || checkcols(board,'O') || checkdiag(board,'O'))
        return WINO;
    
    // Game in progress.
    if (hasmoveleft(board))
        return UNFINISHED;
    
    // Must be a cats game!    
    return CATS;
}
Exemple #2
0
int main(int argc, char** argv) {

	int i, j;

	unsigned long number, largest = 0;

	// left to right
	for (i = 0; i < 17; i++) {
		for (j = 0; j < 17; j++) {
			number = twodim[i][j] * twodim[i][j+1] * twodim[i][j+2] * twodim[i][j+3];

			if (number > largest) {
				printf("%d %d %lu\n", i, j, number);
				largest = number;
			}
		}
	}

	// up down
	for (j = 0; j < 17; j++) {
		for (i = 0; i < 17; i++) {
			number = twodim[i][j] * twodim[i+1][j] * twodim[i+2][j] * twodim[i+3][j];

			if (number > largest) {
				printf("%d %d %lu\n", i, j, number);
				largest = number;
			}
		}
	}

	// check all diagonals
	for (j = 0; j < 17; j++) {
		for (i = 0; i < 17; i++) {
			number = checkdiag(i, j);

			if (number > largest) {
				printf("%d %d %lu\n", i, j, number);
				largest = number;
			}
		}
	}


	euler = largest;

	printf("%llu\n", euler);

return 0;
}