Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ Matrix C++ matrix The city looks like an array of n rows and m columns, and each square in the array contains a house.
C++ Matrix
C++ matrix The city looks like an array of n rows and m columns, and each square in the array contains a house. Thus, each house will have 4 neighbors, if it is not right on the outskirts of the city. Suppose the matrix is the size of 6 x 5, and your friend lives in the house at the coordinates (2, 3). If we draw a diagram of the city in the form of a matrix, it will look like in the drawing below. Each value in the matrix represents the distance to the focus: 32123 21012 32123 43234 54345 65456 Requirement You are given the number of rows (n) and columns ( m) of the matrix that represents your city. In addition, you are given the line and column index of the house where your neighbor, suspected of having the flu, lives. Displays an array n x m containing, for each position (i, j), an integer representing the minimum distance from the neighbor's house coming from the delegation to the house on the position (i, i). Input data On the first line will be the numbers n and m, separated by a space, representing the dimensions of the matrix. On the second line there will be 2 other integers separated by space, representing the line and column index of the neighbor's house. Output data An array of n rows and m columns will be displayed , with items on a line separated by spaces. Each element in the matrix represents the minimum distance to the focus, as required. Restrictions and clarifications 1 s n, m s 100 The numbering of rows and columns starts at 1 1 s line index of the neighbor s house s n 1 s column index of the neighbor s house s mStep 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