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
2010-09-03 16:21:28
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
2010-09-03 16:54:43
@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
2010-09-03 16:58:35
Hooray, a better version.
Nathon
2010-09-03 20:18:00