Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions