Print the square that consists of NxN cells filled with numbers from 1 to N*N in a spiral mode(see examples). Note. Use recursion for solving this problem. Input: Only one line that contains n (1<=n<=100). Output: The matrix in spiral view Samples: No Input Output 1 3 123 894 765 4 1 2 3 4 12 13 14 5 11 16 15 6 10 9 8 7 3 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 24PE
icon
Related questions
Question

Use Python please

Print the square that consists of NxN cells filled with numbers from 1 to N*N in
a spiral mode(see examples).
Note. Use recursion for solving this problem.
Input:
Only one line that contains n (1<=n<=100).
Output:
The matrix in spiral view
Samples:
No Input
Output
1
3
123
894
765
2
4
1 2 3 4
12 13 14 5
11 16 156
10 9 8 7
3
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
Transcribed Image Text:Print the square that consists of NxN cells filled with numbers from 1 to N*N in a spiral mode(see examples). Note. Use recursion for solving this problem. Input: Only one line that contains n (1<=n<=100). Output: The matrix in spiral view Samples: No Input Output 1 3 123 894 765 2 4 1 2 3 4 12 13 14 5 11 16 156 10 9 8 7 3 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning