View Single Post
  #2 (permalink)  
Old 02-11-2008, 03:34 PM
hey hey is offline
Member
 
Join Date: Dec 2007
Posts: 21
hey is on a distinguished road
Hi,

fisrst, how do you like to assign 6 numbers to your moon arrray ?
moon looks like this

? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ?

you have just 6 numbers, so you can do

1 2 3 4 5 6 ? ? ? ?
? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ?
Is it what you want?

next,
to get an element from 2d array, you need to indicate both dimensions: moon[?][?], for instance you need to do moon[0][1]to get an element from the last array
Therefore, you need to use two loops to get each element in the 2d array (unless you wanna do it as in the previous array, if you do, you need to indicate, for example, first dimension as 0)

next, you write:
moon[j][j*3] = m[j];
when you do it that way, you get element, which is located on the crossing of the j raw and j*3 column, this is obviously not what you want to do,
again,you need to use two loops and two variables (i,j) to track all the elements, second to multiply element, you will need to do this
moon[i][j]=m[i]*3;

I am not sure if I understood your idea, but these are some comments

Last edited by hey : 02-11-2008 at 03:36 PM.
Reply With Quote