Spiral matrix - MarisaOJ: Marisa Online Judge

Spiral matrix

Time limit: 1000 ms
Memory limit: 256 MB
Print a spiral matrix of size $n$ rows and $m$ columns. For example, with a matrix of $5$ rows and $6$ columns: ``` 1 2 3 4 5 6 18 19 20 21 22 7 17 28 29 30 23 8 16 27 26 25 24 9 15 14 13 12 11 10 ``` ### Input - A single line containing two integers $n$ and $m$. ### Output - Print the spiral matrix. ### Constraints - $1 \le n, m \le 100$. ### Sample test ``` 3 3 ``` Output: ``` 1 2 3 8 9 4 7 6 5 ```