Question
You are studying different shapes in a plane. In this study, the shapes are referred to as blobs because they are irregularly shaped polygons that
You are studying different shapes in a plane. In this study, the shapes are referred to as "blobs" because they are irregularly shaped polygons that look like blobs even though some of the blobs have centers that are not part of the blob. The blobs are represented in a rectangular grid as a collection of one or more contiguous asterisks (*). Contiguous means that the asterisks must be adjacent either horizontally, vertically or diagonally. Characters in the grid that are not part of a blob are represented by periods (.). In the diagram below, there are 4 blobs shown in different colors.
....***. ..*....* .***.... **.**... .***..** ..**.... **..*..*
Write a program that will determine the number of cells in the blob given the coordinates of a character in the grid. The uppermost, leftmost character of the example above is in row 1, column 1 or location 1 1. Input will from a data file (blob.txt) and the first line of input will contain a single integer n that indicates the number of data sets to follow. For each data set: the first line will contain three integers in the form r c s which meet the following criteria: r 3 is the number of rows in the grid c 3 is the number of columns in the grid s > 1 is the number of test cases for that grid the next r lines will contain the grid. the next s lines will each contain an ordered pair x y, 1 x r and 1 y c, which is the location of a character in the grid. For each test case, you will print the number of cells in the blob that contains the cell at the given location. If the test case falls on a square that is not part of a blob, print "NO BLOB". Let the user input the file name from the keyboard. Use user-defined functions/methods in your program. Do not use break or continue statements.
o O O O k ok
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