Question: In c program language thank you (20 pt) Recall the Sudoku puzzle that you studied in Assignment l.In this work on a similar number placement
In c program language thank you (20 pt) Recall the Sudoku puzzle that you studied in Assignment l.In this work on a similar number placement puzzle known as Magic Square us uestion you will (MS). from the webl A magic square is an arrangement of distinct Here is the description integer numbrow, and in each column, and the numbers in the main (i.e., each nu mber is used once) from 1 to N2 in an NxN square grid, where the numbers in each and secondary diagonals, all add up to the same number, which is N (N + 1) 2. For example, we can place the numbers from 1 to 9 and place the numbers below figures. -3 on a 3x3 MS with the same sum of 15, from 1 to 25-5 on a 5x5 MS with the same sum of 65, as shown in the 7 95 1+15 4 3 8 15 23 6 19 2 15 4 12 25 8 16 10 18 1 14 22 11 24 7 20 3 17 5 13 219 15 15 15 15 15 Suppose we are interested in checking if a given int MS [N] [N] /*initial values /, is a valid Magic Square or not. Also suppose we have the four helper functions in the next page that respectively check if the sum of the numbers in each row, and in each column, and in the main and secondary diagonals are all equal to the same sum (SS)- NN +1)/2. Then we can simply check if a given MS (N] [N] is a valid Magic Square or not as follows: / suppose all standard C libraries are included here / #define N / the number N can be large in an actual program void main() int MS [N] [N] 12,7,61 (4,3,81)i int Ss(N(N N+1)/2) if(allRowsOK (MS, SS)&&allColumnsOK (MS, ss)&& mainDiagoK (MS, Ss)&&secondaryDiagoK (MS, SS) ) printf ("YES, this is a Magic Square! In") else printf("No, this is NOT a Magic Square! In")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
