tags:

views:

60

answers:

1

I have been trying to figure out how can we print a array hellically but i am stuck on how to get started.Any algorithms or ideas will be very helpful.Thanks HELLICALLY means printing the array in concentric circular shape

+1  A: 

If I'm interpreting what you're saying correctly, you want to print the contents of an array, but in a spiral.

I would start by allocating a big rectangular block of memory (a 2-D array) and initializing it to zero. This represents the screen. Then devise a function for determining the coordinates of the next point in the circle and make some coordinate variables initialized to the origin point. Fill the screen by dropping array members wherever they go.

Print out the screen-array, one row at a time, but substitute space for zero.

Screen size and next-coordinate-function are left as exercises for the reader.

Nathon
This should work for concentric circles too. The next-coordinates function just has to draw circles instead of a spiral. It might be easiest to do this in polar coordinates (r, theta) and pass those to another conversion function to get your 2-D array coordinates.
Nathon
@Nathon The easiest way to map a circle onto a 2D array is the Midpoint Circle Algorithm: http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
Spencer Nelson
Hooray, a better version.
Nathon