In this lab, you are not allowed to use any libraries other than stdio.h and std
ID: 3766392 • Letter: I
Question
In this lab, you are not allowed to use any libraries other than stdio.h and stdlib.h. 100 marks will be deducted if you use other libraries. Task 1: You should have played MineSweeper. How about MinoMarker? In a minefield, people have successfully identified the locations of the mines and deactivated some of them, but could not remove any of them. Thus, they mark the mines on a map, represented hero as a 2D array. Each element in the array represents a small area in the minefield However after marking the mines that way, the mine detectors realize that the effect of a mine may be larger than the area in one element. Hence, they want to re-mark the mines as follows: In this task, you need to write a program to create a now map of the minefield from the original map, following the rules above. You can assume that no 2 mines are close enough that their encoded elements overlapped. However, the mines may lie on the boundary of the map. The input of your program starts with the height and the width of the map Each of the next lines in the input shows one row of the map Your pro cum should print out the new map with the mines re-encoded. It should also contain the following functions: This function should scan the field dimension; into the variable; at addresses row; and cols, as well as the 2D array. Those numbers are entered by the user. You mould allocate the necessary memory from the heap according to the dimensions. Note that the address of the local variable is passed to this function instead of the variable itself where field is the minefield, rows and cols are the dimensions of the map In this function, you should remark the field according to the description oar lice. Note the use of const. where field is the minefield, rows and cols are the dimensions of the map This fraction prints out the updated map of the minefield. Finally, after you prim out the field, you should deallocate the memory in the following function where field is die pointer to the 2D array. A file named "q1_templato.c" has boon provided for you and you should net change the main function.Explanation / Answer
#include<stdio.h>
#define mine 'M'
#define space " "
void readfield(int rows,int cols,int )
{
int i =0;
int j=0;
int a =0;
int b=0;
int constatnt;
char mine =minefield;
total = size* size;
total=(float) (float) total
printf("%d ",int);
for(i=0;i<number;i++)
{
int row,col;
row = number ()%size;
col =number () % size;
printf("%c %d %d ",minfiled,col,row);
minfield[row][col]=mine;
printf("/n");
for(i=0;i<s;i++)
{
for(j=0;j<size;j++)
{
if (minefield [i][j]=space)
{
if(j==0)
{
for(a=0;a<size;a++)
{
if(minfield[i][j]==mine)
{
count++;
}
}
printf(minfiled,szie);
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.