Ejemplo n.º 1
0
int main()
{
	// Game Board
	int myBoard[N][N];

	// Game Board Pointer
	int* myBoardPointer = (int*)myBoard;

	// Initialize Array with Default Values
	initialize2DArray(myBoardPointer);

	randomizeBoard(myBoardPointer);

	std::cout << "Original Board:\n";
	print2DArray(myBoardPointer);

	if (solveSudoku(myBoardPointer))
	{
		std::cout << "Solved: \n";
		print2DArray(myBoardPointer);
	}
	else
	{
		std::cout << "No Solution Exists: \n";
	}
		

	
	

	return 1;
}
Ejemplo n.º 2
0
int main(int argc, char** argv) {

    srand(time(NULL));
    Square** board = randomizeBoard();
    int gameOver, gameWon, i;
    while(1)
    {
        printBoard(board);
        
        int gameWon = checkGameState(board);
        if(gameWon == 1)
        {
            printf("\nYou won! Congratulations!\n");
            return 0;
        }
        printf("\n\nEnter the row of the space you want to hit: ");
        int row;
        scanf("%d", &row);

        printf("\nEnter the column of the space you want to hit: ");
        int column;
        scanf("%d", &column);
        
        gameOver = updateBoard(board, row, column);
        if(gameOver == 1)
        {
            printf("\nYou hit a mine! Game Over");
            printUncoveredBoard(board);
            return 0;
        }
        
    }
    free(board);
    for(i = 0; i < SIZE; i++)
    {
        free(board[i]);
    }
    return (EXIT_SUCCESS);
}