Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in C to play a game of Sudoku with the user. The goal of the game is to fill in missing numbers

Write a program in C to play a game of Sudoku with the user. The goal of the game is to fill in missing numbers in an 9x9 array. Each number in the set [1-9] must be found in every row, every column, and every 3x3 block in the array.

The user should be able to set entries in the game board by providing input in the form row,column,value to solve a specific square, or enter -1 to exit the program.

When the user has filled in all blank spaces in the game board, the program should determine if the current board is a valid solution and inform the user accordingly. Note that a Sudoku board could have multiple solutions! The solution provided with the initial puzzle may not be the only valid solution the user could provide. Thus, you should not simply compare the user's input to the original solution. Instead, you need to test the user's solution against the Sudoku rules previously described.

Use a two-dimensional array of integers to store the current state of the puzzle. In this array, values of 1-9 represent user input, and a value of -1 represents a space with no current value. As the game is played, update this array based on user input.

You must use dynamic memory allocation to store this array. Remember to release dynamic memory before exiting! How can this be accomplished? In C, a two-dimensional array is simply an array of arrays, and you can allocate a single-dimensional array using malloc() or calloc().

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

A7.18 What is an associated company? (Section 7.8.5)

Answered: 1 week ago

Question

When would you use one approach, and when would you use another?

Answered: 1 week ago