Question: Write a program that reads an integer number N (0 N 100) that corresponds to the order of a two dimensional array of integers, and

Write a program that reads an integer number N (0 N 100) that corresponds to the order of a two dimensional array of integers, and builds the Square Matrix Array according to the above example. Please use functions and in C++ please! idk how to comment but here's the answer for anyone who needs

#include

#include

using namespace std;

int main() {

//data abstraction

const int MAX = 100;

int n, matrix[MAX][MAX], rows, collums;

int v1, v2;

do{

//input

cin >> n;

if(n != 0){

//data processing

for(rows = 1; rows <= n; rows++){

for(collums = 1; collums <= n; collums++){

v1 = n - rows + 1;

v2 = n - collums + 1;

matrix[rows - 1][collums - 1] =

min(min(rows, collums), min(v1, v2));

}

}

//output

for(rows = 0; rows < n; rows++){

for(collums = 0; collums < n; collums++){

cout << setw(3) << matrix[rows][collums] << " ";

}

cout << endl;

}

}

else{}

}

while(n != 0);

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!