Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order in C++
Input: 3 Output: [ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ] ] Before looking into the solution, I recommend you to please go through print matrix…