Short C Progam THANK YOU!!! LINK TO ORGINAL PDF HERE: https://sparta.cs.ucf.edu/
ID: 3682356 • Letter: S
Question
Short C Progam
THANK YOU!!!
LINK TO ORGINAL PDF HERE:
https://sparta.cs.ucf.edu/index.php?option=com_sparta&controller=problems&task=download&format=raw&problemID=21
Skyler is really good at math. The thing he is best at is finding X. But he doesn’t like algebra at all (it’s just too boring); so, instead he likes to find Xs on the page!
In middle school he was satisfied with just finding the letter ‘X’; however, after he advanced to high school he is now interested in finding larger Xs. He noticed that large Xs (consisting of two intersecting diagonals, each with consecutive Xs) can occur in various designs. Some large Xs intersect between characters while others intersect precisely on a single character. Within the latter group, some intersect exactly on the center X; call these large Xs perfect. For example, Page A below has a perfect X of size 5 because the two diagonals (each containing 5 Xs) intersect through a single character and it is the center X in both diagonals. Page B has an X (of size 4) that intersects between characters so it is not a valid perfect X; however, a single X is always considered perfect so Page B has multiple perfect Xs of size 1. Page C has an X that intersects through a single character but is only a perfect X of size 3 (the larger X does not intersect through the center X of both diagonals). Note that Xs on the end of a diagonal (or even on other parts of the page) may be ignored in the interest of forming a larger perfect X.
Skyler would like to be able to find the largest such perfect X on a page. He would like you to write a program that can help him! The largest perfect X is the perfect X with the largest size.
The Problem:
Given lines from a page of paper, find the largest perfect X on the page.
The Input:
The first line of input will be a single positive integer, n, representing the number of pages to read. Each page will begin with two postive integers, l and w (l < 50; w < 50), representing the number of lines on this page and the length of each line, respectively. Each of the next l lines of input will each contain exactly w characters. Each character will be an uppercase letter, and it is guaranteed that the letter ‘X’ will appear at least once on each page.
The Output:
For each page, first output “Page #i: ” where i is the number of the page (beginning with 1), followed by a single integer representing the size of the largest perfect X on the page.
Sample Input:
3
3 3
UPU
CXC
FTF
5 5
XABCX
DXEXF
GHXIJ
KXLXM
XNOPX
3 6
AXEAXE
SIXXES
OXYOXY
Sample Output:
Page #1: 1
Page #2: 5
Page #3: 1
Page A Page B Page C XOOOX OXOXO OOXOO OXOXO XOOOX XOOX OXXO OXXO XOOX XOOOX OXXXO OXXXO OXXXO Valid Perfect X of Size 5Multiple Perfect Xs of Size 1Valid Perfect X of Size 3Explanation / Answer
#include #include void main() { int a[25], i, large, small, n; clrscr(); printf("Enter the size of array(max 25) "); scanf("%d", &n); printf("Enter any %d integer array elements ",n); for(i = 0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.