HI, Thank You. Consider a square grid, some of whose cells are empty and others
ID: 3538652 • Letter: H
Question
HI,
Thank You.
Consider a square grid, some of whose cells are empty and others contain an asterisk. Define two asterisks to be contiguous if they are adjacent to each other in the same row or in the same column. Now suppose we define a blob as follows: A blob contains at least one asterisk. If an asterisk is in a blob, then so is any asterisk that is contiguous to it. If a blob has two or more asterisks, then each asterisk in it is contiguous to at least one other asterisk in the blob. For example, there are four blobs in the partial grid seven blobs in and only one in Write a program that uses a recursive function to count the number of blobs in a square grid. Input to the program should consist of the locations of the asterisks in the grid, and the program should display the grid and the blob count.Explanation / Answer
SLIGHT MODIFICATION IN THIS CODE WILL PRINT THE GRID... DONT FORGET TO CHANGE THE X and Y VALUES while calling setAsterisk function, depending on your question. COmment for any doubts ! :) #include #include typedef struct area{ char ch; int marker; }blob; void setAsterisk(int a, int b, blob **arr){ arr[a][b].marker='*'; } void printGrid(int a, int b, blob **arr){ int i,j; for(i=0;i
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.