Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***********************The program is C++*********************** A magic square is a 2d square array (# of rows equals # of columns) of positive integers with these properties:

***********************The program is C++***********************

A magic square is a 2d square array (# of rows equals # of columns) of positive integers with these properties:

if n is the array's number of rows and number of columns then

1) the numbers range from 1 to n^2

2) every number in the range appears exactly once

3) the sum of the numbers in a row, in a column, in a diagonal, in an anti-diagonal equals n(n^2 + 1) /2.

4) for any diagonal element, the element's row index equals the element's column index

5) for any anti-diagonal element, the sum of the element's row index and the element's column index equals n - 1.

Write 2 boolean functions that return true if their parameter or parameters define a magic square of false if their parameter or parameters do not define a magic square.

The first function's parameters define a dynamic 2D array, and the second function's parameters define a 2D vector.

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

Step: 3

blur-text-image

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

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions