Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C program that includes the functions listed as follows: clearField(.): Takes a 20x20 2-dimensional integer array that represents a minefield. The function must
Write a C program that includes the functions listed as follows: clearField(.): Takes a 20x20 2-dimensional integer array that represents a minefield. The function must assign all elements to 0. putMine (.): Takes a 20x20 2-dimensional integer array (minefield), and two integers row and column. The function must assign the element at [row.column] in the array to -1. processField(.): Takes 20x20 2-dimensional integer array (minefield). In the minefield, -1 represents a mine is placed at that location. The function must fill the elements other than the mines with the number of mines that the element is neighbor to (including diagonal neighbors). printField(.): Takes 20x20 2-dimensional integer array (minefield). The function must print the field by printing '*' instead of'-1' for the mines. main(): Creates a minefield, clears it by using clearField() and puts arbitrary number of mines to the minefield by using putMine() function. After that, the minefield must be processed and printed by using processField() and printField() functions. Example: For a field of 4x4 first the following array is created. 0000 0000 0000 0000 Then some mines are put as follows. 00-10 0000 0-100 000-1 Then, after processing the field, it is as follows. 01-11 1221 1-121 112-1 Also, it is printed as follows. 01* 1 1221 1* 21 112*
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started