Saturday, March 24, 2012

Print matrix spirally.

Write a program to print a 2-D array spirally- i.e, starting at a corner and spiraling inwards.


printing input matrix: 
1 2 3 4 5 6 
7 8 9 10 11 12 
13 14 15 16 17 18 


printing matrix spirally: 
1 2 3 4 5 6 12 18 17 16 15 14 13 7 8 9 10 11 

No comments:

Post a Comment