Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

An n n matrix that is filled with the numbers 1, 2, 3, . . ., n^2 is a magic square if the sum of

An n n matrix that is filled with the numbers 1, 2, 3, . . ., n^2 is a magic square if the sum of the elements in each row, in each column, and in the two diagonals is the same value.

Write a program that reads in 16 values from the keyboard and tests whether they form a magic square when put into a 4 4 vector. You need to work on three tasks:

Process the input into the form of 2 dimensional vector form, i.e., You need to fill in the write vector to square function. Print out the square. That is, you print 4 numbers in each line and use a space to separate them. The square should have 4 lines. You need to fill in the print square function. When the numbers are put into a square, check whether the sums of the rows, columns, and diagonals equal to each other, i.e., You need to fill in the is magicsquare function. Hint If the matrix is magic square, then all of its row sums, column sums and diagonal sums should equal to (1 + 2 + + 15 + 16)/4 = 34.

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

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions

Question

Bring out the limitations of planning.

Answered: 1 week ago

Question

Why should a business be socially responsible?

Answered: 1 week ago

Question

Discuss the general principles of management given by Henri Fayol

Answered: 1 week ago

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago

Question

=+8. Why is productivity important?

Answered: 1 week ago

Question

=+ 9. What is inflation and what causes it?

Answered: 1 week ago

Question

=+6. What does the invisible hand of the marketplace do?

Answered: 1 week ago