Logic Builder # 2

Magnet December 26th, 2006

Write a routine that prints out a 2-D array in spiral order!

i.e. You are given two dimensional array

[0][0] [0][1] [0][2] [0][3]
[1][0] [1][1] [1][2] [1][3]
[2][0] [2][1] [2][2] [2][3]
[3][0] [3][1] [3][2] [3][3]
[4][0] [4][1] [4][2] [4][3]

it should print array elements in following order:-

1) Outside to inside:-

Option 1

2) Inside to outside:-

Option 2

Trackback URI | Comments RSS

Leave a Reply