...

View Full Version : Two Dementional Array Spiral Fill



turtlegk33
02-15-2008, 04:00 AM
How could i write two methods... one recursive and one not to fill a two dementional array of size n.

ex. 5 x 5 array

0 1 2 3 4
15 16 17 18 5
14 23 24 19 6
12 22 21 20 7
12 11 10 9 8


the non-recursive routine would be like void spiralFill(int [][]a, int n) where it spiral fills the first n rows and columns

Aradon
02-15-2008, 04:24 PM
There are a couple of ways to do this, but we wont do it for you! What have you come up with for ideas thus far?

For the non-recursive way, think about how you would go adding to each element in the array. It may help to do the non-recursive part first, then move onto the recursive part (assuming you're a newer student, this would be easier).

Think about how he array's are filled, and how you could possibly loop that.

Let us know what you come up with.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum