Write a C++ program that fills random squares of 3 by 3, with unique numbers from 1 to 9, and tests if the generated matrix forms a Magic Squares.
Your program should loop until three magic squares are generated and printed to the screen.
Finally before exiting, the program should print the number of tries it took to achieve the task.