Print the square that consists of NxN cells filled with numbers from 1 to N*N in a spiral mode(see examples).

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

Please use Java and RECURSION

Moreover, i am a pythonist. So can u please write very detailed answer. For example print(x) in python is the same thing as System.out.println(x).

 

Please) Thanks in advance!

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
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Computational Systems
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