Help ! I am still a beginner in C++, and we were tasked with a final project on magic square.
The objective is to have the program accept values in a form of 3 rows and 3 columns. The rows, columns, and diagonals should separately equal 9, and then I must check for those values at the end.
I was given a template to work with, which is below. I need help getting a jump start on how to do the individual functions. Especially entering the values, such that in the output, it also reads: ROW 0, COLUMN 0, or ROW 1, COLUMN 0 -- when it asks the person to enter the value. I know I need a loop for this to work, but I am lost on how to organize the code, and thus very discouraged. Anything helps!!.. We are also instructed to just limit our topics to loops, conditionals, and arrays.
Thanks !!
#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()
{
int arrayRow1[ROWS];
for (int index = 0; ROWS>index; index++)
{
cout << "Enter number for row " << index; ": "
cin >> arrayRow1[index];
}
/* 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