Spiral Matrix

5

2 votes
Problem

Given the value of n, print a n*n matrix in spiral form.

Example : For n = 3,

1 2 3

8 9 4

7 6 5

There will be multiple test-cases.

Input :

The first line contains a single integer, t - the number of test cases.

The next t lines contain a single integer each, the value of n.

Output :

Print the desired matrix in spiral format.

Constraints :

1<=t<=5

1<=n<=25

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?