I am trying to find magic squares in C++ for a given NxN array. I need a method to go over all possible combinations of numbers from 1 to n^2.
I had a solution similar to bogo sort which just shuffled the array until a solution was found which is obviously a bad way but it worked for a 3x3 array.
I assume the way to go over all combinations would be using some kind of recursion function but I can't figure it out.
Aucun commentaire:
Enregistrer un commentaire