please help me Write a program to generate a 5 times 5 magic
please help me
Write a program to generate a 5 times 5 magic square using the Simulated Annealing search algorithm. Your program should print the output like the following example: 11 24 7 20 3 4 12 25 8 16 17 5 13 21 9 10 18 1 14 22 23 6 19 2 15 Also print out the execution time of the code that finds the solution (don\'t include the input/output time). A 5 times 5 magic square is a square that contains the numbers between 1 and 25 that has the property that all its rows, columns, and diagonals sum to an equal value = 65 (as you can sec from the above example). For your implementation consider the sum of the absolute difference between the sum of each row, column, and diagonal from 65 to be your heuristic function (fitness function). Notice that h(magic square) is equal to zero. Also use the operation of swapping two random numbers to be your action of generating a child for the current node. Your program should start by generating a random 5 times 5 square (note that numbers can\'t be repeated) and then start improving on this state until reaching a goal(magic square) by the guidance of the fitness function. Remember that simulated annealing algorithm starts by allowing bad moves with a given probability then lowers that probability as we approach the goal, this probability should never reach zero or your algorithm will get stuck at a local minimum.Solution
magic sqr logic all the sum of all row ele or all col ele or all diagonal ele should be same
int main()
{
int size = 5;// taken size as 5 for example
int matrix[size][size]; // row and column r 4
int row=0;
int col = 0;
int sum, summ, summm;
int x = 0;
printf(\"\ Enter the matrix ele : \");
for (row = 0; row < size; row++) {
for (col = 0; col < size; col++)
scanf(\"%d\", &matrix[row][col]);
}
//logic for diagonal ele
sum = 0;
for (row = 0; row < size; row++)
{
for (col = 0; col < size; col++)
{
if (row == column)
sum = sum + matrix[row][col];
}
}
//For the ele in rows
for (row = 0; row < size; row++)
{
sum1 = 0;
for (col = 0; col < size; col++)
{
summ = summ + matrix[row][col];
}
if (sum == summ)
x = 1;
else {
x = 0;
break;
}
}
//For the ele in columns
for (row = 0; row < size; row++)
{
summm = 0;
for (col = 0; col < size; col++)
{
summm = summm + matrix[col][row];
}
if (sum == summm)
x = 1;
else {
x = 0;
break;
}
}
if (flag == 1)
printf(\"\ Magic square\");
else
printf(\"\ No Magic square\");
return 0;
}

