Magic Square Algorithm C++