Question
In C++ preferably. Java can also be used. Given a square grid of uppercase letters, write a program to find the largest square formed around
Given a square grid of uppercase letters, write a program to find the largest square formed around a given location called the center. The location of each character in the grid is given by an ordered pair (r,c) that indicates the row r and the column c of a character relative to the origin. The origin is the top left position of the grid and is position (0,0). A largest square is the largest contiguous s x s area that contains only the same letter as its center. Input will be from a data file where; the first line will contain a single integer n that indicates the number of data sets to follow. The first line of each data set will contain a single integer p indicating the number of rows and columns in the square matrix of uppercase letters to follow. The next p lines will contain the p x p square matrix. The following line will contain a single integer m that indicates the number of center locations (r, c) to follow. Each of the next m lines will contain two integers r and c that represent the center for which you are to find the largest square. For each labeled data set, output to the screen (r c) s where r and c are the row and column of the center of the largest square and s is the number of letters in an edge of the largest square that contains only the same letter as its center. One blank line should be printed between sets of output. Let the user input the file name from the keyboard. If coding in C++, use the STL string class. Refer to the sample output below. Sample File: Sample Run: 2 9 AAABBBAAA AAABBBAAA AAABBBAAA AAABBBAAA AABBBBBBB AABBBBBBB ABBBBBBBB BBBBBBBBB BBBBBBBBB Enter file name: squares.txt Data Set 1: (3 2) 1 (1 1) 3 (6 5) 5 Data Set 2: (1 2) 3
COSC 2436 S22 7 3 3 2 1 1 6 5 5 BBBBB BBBBB BBBBB BBBBB BBBBB 2 1 2 2 2 (2 2) 5 Name the program: LargestSquareXX.java or LargestSquareXX.cpp, where XX are your initials.
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