Write a program that simulates a magic square using 3 one-dimensional parallel arrays of integer type. Each one the arrays corresponds to a row of the magic square. The program asks the user to enter the values of the magic square row by row and informs the user if the grid is a magic square or not.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Processing Requirements

 

Start from scratch.

Use the following template to start your project:

 

#include<iostream>

using namespace std;

 

// Global constants

const int ROWS = 3;  // The number of rows in the array

const int COLS = 3;  // The number of columns in the array

const int MIN = 1;  // The value of the smallest number

const int MAX = 9;  // The value of the largest number

 

// Function prototypes

bool isMagicSquare(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size);

bool checkRange(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size, int min, int max);

bool checkUnique(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size);

bool checkRowSum(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size);

bool checkColSum(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size);

bool checkDiagSum(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size);

void fillArray(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size);

void showArray(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size);

 

int main()

{

     

        /* Define a Lo Shu Magic Square using 3 parallel arrays corresponding         to each row of the grid */

        int magicArrayRow1[COLS], magicArrayRow2[COLS], magicArrayRow3[COLS];

        // Your code goes here

 

      return 0;

}

// Function definitions go here

bool sheckpansetint arrayRow1[], int arrayRow2[], int arrayRow3[], int size, int min, int
max);
bool sheckvoiAvetint arrayRow1[], int arrayRow2[], int arrayRow3[], int size);
bool checkBowSuntint arrayrow1[], int arayrow2[], int arrayrow3[], int size);
bool sheckGoSuntint arrayrow1[], int arrayrow2[], int arrayrow3[], int size);
bool checkDiasSURtint arrayrowi[], int arrayrow2[], int arrayrow3[], int size);
void APOReint arrayRowl[], int arrayRow2[], int arrayRow3[], int size);
void showAPOANEint arrayrow1[), int arrayrow2[], int arrayrow3[], int size);
int maine
/* Define a Lo Shu Magic Square using 3 parallel arrays corresponding
to each row of the grid */
int magicArrayRowl (COLS], magicArrayRow2 [COLS), magicArrayRow3 [COLSL:
// Your code goes here
return
// Function definitions go here
Do not repeat any source code segment you submitted in previous semesters.
Create and use at least the following functions:
void fiUArtayfint arrayrow1[], int arrayrow2[), int arrayrow3[], int
size) - Accepts 3 int arrays and a size as arguments, and fills the arrays out
with values entered by the user. First argument corresponds to the first row
of the magic square, second argument to the second row and the third
argument to the third row of the magic square
void showArravtint arrayRow1[], int arrayRow2[], int arrayRow3[],
int size) - accepts 3 int arrays and a size as arguments and displays their
content.
Example:
135 farrayRow1)
679 farrayRow2)
8 24 tarrayRow3)
bool isMagicSaMAretint arrayRow1[], int arrayRow2[], int
arrayRow3[], int size) - accepts 3 int arrays and a size as arguments and
returns true if all the requirements of a magic square are met. Otherwise, it
returns false. First argument corresponds to the first row of the magic
square, second argument to the second row and the third argument to the
third row of the magic square.
bool checkRange(int arrayRow1[], int arrayRow2[], int arrayRow3[],
int size, int min, int max) - accepts 3 int arrays, a size and a min and max
value as arguments and returns true if the values in the arrays are within the
specified range min and max. Otherwise, it returns false. First argument
corresponds to the first row of the magic square, second argument to the
second row and the third argument to the third row of the magic square.
bool checkUoique(int arrayRow1[], int arrayRow2[], int
arrayRow3[], int size) - accepts 3 int arrays and a size as arguments, and
returns true if the values
the arrays are unique (only one occurrence of
numbers between 1-9). Otherwise, it returns false. First argument
corresponds to the first row of the magic square, second argument to the
second row and the third argument to the third row of the magic square.
bool checkRowSum(int arrayRow1[], int arrayRow2[], int
arrayRow3[], int size) - accepts 3 int arrays and a size as arguments and
returns true if the sum of the values in each of the rows are equal.
Otherwise, it returns false. First argument corresponds to the first row of the
magic square, second argument to the second row and the third argument to
the third row of the magic square.
bool checkColsHm(int arrayRow1[], int arrayRow2[], int
arrayRow3[], int size) - accepts 3 int arrays and a size as arguments and
returns true if the sum of the values in each of the columns are equal.
Otherwise, it returns false. First argument corresponds to the first row of the
magic square, second argument to the second row and the third argument to
the third row of the magic square.
bool checkDiagSum(int arrayrow1[], int arrayrow2[], int
arrayrow3[], int size) - accepts 3 int arrays and a size as arguments and
returns true if the sum of the values in each of the array's diagonals are
equal. Otherwise, it returns false. First argument corresponds to the first row
of the magic square, second argument to the second row and the third
argument to the third row of the magic square.
[NOTE: You can create and use more functions as needed.]
Transcribed Image Text:bool sheckpansetint arrayRow1[], int arrayRow2[], int arrayRow3[], int size, int min, int max); bool sheckvoiAvetint arrayRow1[], int arrayRow2[], int arrayRow3[], int size); bool checkBowSuntint arrayrow1[], int arayrow2[], int arrayrow3[], int size); bool sheckGoSuntint arrayrow1[], int arrayrow2[], int arrayrow3[], int size); bool checkDiasSURtint arrayrowi[], int arrayrow2[], int arrayrow3[], int size); void APOReint arrayRowl[], int arrayRow2[], int arrayRow3[], int size); void showAPOANEint arrayrow1[), int arrayrow2[], int arrayrow3[], int size); int maine /* Define a Lo Shu Magic Square using 3 parallel arrays corresponding to each row of the grid */ int magicArrayRowl (COLS], magicArrayRow2 [COLS), magicArrayRow3 [COLSL: // Your code goes here return // Function definitions go here Do not repeat any source code segment you submitted in previous semesters. Create and use at least the following functions: void fiUArtayfint arrayrow1[], int arrayrow2[), int arrayrow3[], int size) - Accepts 3 int arrays and a size as arguments, and fills the arrays out with values entered by the user. First argument corresponds to the first row of the magic square, second argument to the second row and the third argument to the third row of the magic square void showArravtint arrayRow1[], int arrayRow2[], int arrayRow3[], int size) - accepts 3 int arrays and a size as arguments and displays their content. Example: 135 farrayRow1) 679 farrayRow2) 8 24 tarrayRow3) bool isMagicSaMAretint arrayRow1[], int arrayRow2[], int arrayRow3[], int size) - accepts 3 int arrays and a size as arguments and returns true if all the requirements of a magic square are met. Otherwise, it returns false. First argument corresponds to the first row of the magic square, second argument to the second row and the third argument to the third row of the magic square. bool checkRange(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size, int min, int max) - accepts 3 int arrays, a size and a min and max value as arguments and returns true if the values in the arrays are within the specified range min and max. Otherwise, it returns false. First argument corresponds to the first row of the magic square, second argument to the second row and the third argument to the third row of the magic square. bool checkUoique(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size) - accepts 3 int arrays and a size as arguments, and returns true if the values the arrays are unique (only one occurrence of numbers between 1-9). Otherwise, it returns false. First argument corresponds to the first row of the magic square, second argument to the second row and the third argument to the third row of the magic square. bool checkRowSum(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size) - accepts 3 int arrays and a size as arguments and returns true if the sum of the values in each of the rows are equal. Otherwise, it returns false. First argument corresponds to the first row of the magic square, second argument to the second row and the third argument to the third row of the magic square. bool checkColsHm(int arrayRow1[], int arrayRow2[], int arrayRow3[], int size) - accepts 3 int arrays and a size as arguments and returns true if the sum of the values in each of the columns are equal. Otherwise, it returns false. First argument corresponds to the first row of the magic square, second argument to the second row and the third argument to the third row of the magic square. bool checkDiagSum(int arrayrow1[], int arrayrow2[], int arrayrow3[], int size) - accepts 3 int arrays and a size as arguments and returns true if the sum of the values in each of the array's diagonals are equal. Otherwise, it returns false. First argument corresponds to the first row of the magic square, second argument to the second row and the third argument to the third row of the magic square. [NOTE: You can create and use more functions as needed.]
Project Description
The Lo Shu Magic Square
The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below:
4
9
2
3
5
7
1
6
The Lo Shu Magic Square has the following properties:
• The grid contains the numbers 1 through 9 exactly.
• The sum of each row, each column, and each diagonal all add up to the same
number. This is shown below:
15
4
9
2
+ 15
3
5
7
+ 15
8
6
+15
15
15
15
15
Write a program that simulates a magic square using 3 one-dimensional parallel
arrays of integer type.
Each one the arrays corresponds to a row of the magic square.
The program asks the user to enter the values of the magic square row by row and
informs the user if the grid is a magic square or not.
See the sample outputs for more clarification.
Project Specifications
Input for this project:
Values of the grid (row by row)
Output for this project:
Whether or not the grid is magic square
Programmer's full name
Project number
Project due date
Processing Requirements
Start from scratch.
Use the following template to start your project:
#include<iostream>
using namespace
// Global constants
const int ROWS = The number of rows in the array
The number of columns in the array
The value of the smallest number
The value of the largest number
const int COLS=
const int MIN =
const int MAX = 9
// Function prototypes
bool isMagissquaRetint arrayRow1[], int arrayRow2[], int arrayRow3[], int size);
Transcribed Image Text:Project Description The Lo Shu Magic Square The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below: 4 9 2 3 5 7 1 6 The Lo Shu Magic Square has the following properties: • The grid contains the numbers 1 through 9 exactly. • The sum of each row, each column, and each diagonal all add up to the same number. This is shown below: 15 4 9 2 + 15 3 5 7 + 15 8 6 +15 15 15 15 15 Write a program that simulates a magic square using 3 one-dimensional parallel arrays of integer type. Each one the arrays corresponds to a row of the magic square. The program asks the user to enter the values of the magic square row by row and informs the user if the grid is a magic square or not. See the sample outputs for more clarification. Project Specifications Input for this project: Values of the grid (row by row) Output for this project: Whether or not the grid is magic square Programmer's full name Project number Project due date Processing Requirements Start from scratch. Use the following template to start your project: #include<iostream> using namespace // Global constants const int ROWS = The number of rows in the array The number of columns in the array The value of the smallest number The value of the largest number const int COLS= const int MIN = const int MAX = 9 // Function prototypes bool isMagissquaRetint arrayRow1[], int arrayRow2[], int arrayRow3[], int size);
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education