Write a C++ program to get an ODD integer (3<=n<=7) and construct an n by magic square. n
Write a C++ program to get an ODD integer (3<=n<=7) and construct an n by magic square. n
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question

Transcribed Image Text:A magic square is an n by n matrix in which each of the integers 1, 2, 3...n appears exactly once
and all column sums, row sums, and diagonal sums are equal. For example, the following is a 5
by 5 magic square in which all rows, columns and diagonals sum to 65.
17
24
1
8.
15
23
7
14
16
4
6.
13
20
22
10
12
19
21
3
11
18
25
9
The following is a procedure for constructing an n by n magic square for any ODD integer n.
Place 1 in the middle of the top row. Then.m after integer k has been placed, move up one row
and one column to the right to place the next integer k+1 unless one of the following occurs: If a
move takes you above the top row in the jth column, move to the bottom of the jth column and
place k+1 there. If the move takes you outside to the right of the square in the ith row place k+1
in the ith row in the left side. If the move takes you to an already filled square or if you move out
of the square at the upper right hand corner place k+1 immediately below k.
Write a C++ program to get an ODD integer (3<=n<=7) and construct an n by n magic square.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY