Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
An imaginary compiler uses an imaginary array ordering to represent multi-dimensional arrays into 1-D arrays.Say,this imaginary ordering is called spiral ordering.It works like:
Given 2-D array-{{1,2,3,4}{5,6,7,8}{9,10,11,12}{13,14,15,16}} then the 1-D array will be {1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10}
Deduce the general formula for calculating the address of an element at (x,y) position in a 2-D array,given the address of the element at (0,0).
Posted
Comments
Patrice T 26-Sep-15 17:37pm    
Looks like homework !
Have you deviced a formula ? Imaginary speaking :)
Member 12011302 27-Sep-15 4:10am    
Am able to print the matrix in Spiral form but have not yet deviced the formula...confused about that one!Help will be appreciated!

1 solution

As an imaginary responder I imagine this is your homework, so don't expect other people to do it for you.
 
Share this answer
 
Comments
Member 12011302 27-Sep-15 4:11am    
Can you just help me device the general formula?I have written a code that will print matrix in spiral form but confused about the address part...
Richard MacCutchan 27-Sep-15 7:49am    
Not really, since I do not understand the question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900