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
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