mrvanx
3rd April 2007, 11:31 PM
Hey people, I may be being a bit newb-ish here but I just cant get how this is done:
(Code is C++)
Im trying to fill a 3d array with values, for readability i am addressing the 3rd dimension of it manually but i have written the following. The syntax is identical to a 2d array (a 2d array of size 4x2).
int pattern1[11][4][2],pattern2[11][4][2];
...
pattern1[0]={{-1,0},{-2,-1},{-3,-2},{-4,-3}};
pattern1[1]={{-1,-1},{-2,-2},{-3,-3},{-4,-4}};
pattern1[2]={{0,-1},{-1,-2},{-2,-3},{-3,-4}};
pattern1[3]={{0,-1},{0,-2},{-1,-3},{-2,-4}};
pattern1[4]={{0,-1},{0,-2},{0,-3},{-1,-4}};
pattern1[5]={{0,-1},{0,-2},{0,-3},{0,-4}};
pattern1[6]={{0,-1},{0,-2},{0,-3},{1,-4}};
pattern1[7]={{0,-1},{0,-2},{1,-3},{2,-4}};
pattern1[8]={{0,-1},{1,-2},{2,-3},{3,-4}};
pattern1[9]={{1,-1},{2,-2},{3,-3},{4,-4}};
pattern1[10]={{1,0},{2,-1},{3,-2},{4,-3}};
pattern2[0]={{-1,-1},{-1,-2},{-1,-3},{-1,-4}};
pattern2[1]={{0,-1},{0,-2},{0,-3},{0,-4}};
pattern2[2]={{1,-1},{1,-2},{1,-3},{1,-4}};
pattern2[3]={{1,-1},{2,-2},{2,-3},{2,-4}};
pattern2[4]={{1,-1},{2,-2},{3,-3},{3,-4}};
pattern2[5]={{1,-1},{2,-2},{3,-3},{4,-4}};
pattern2[6]={{1,-1},{2,-2},{3,-3},{4,-3}};
pattern2[7]={{1,-1},{2,-2},{3,-2},{4,-2}};
pattern2[8]={{1,-1},{2,-1},{3,-1},{4,-1}};
pattern2[9]={{1,0},{2,0},{3,0},{4,0}};
pattern2[10]={{1,1},{2,1},{3,1},{4,1}};
However i am getting compiler errors!?! Is this the correct way to assign values or am i waaay off??
(Code is C++)
Im trying to fill a 3d array with values, for readability i am addressing the 3rd dimension of it manually but i have written the following. The syntax is identical to a 2d array (a 2d array of size 4x2).
int pattern1[11][4][2],pattern2[11][4][2];
...
pattern1[0]={{-1,0},{-2,-1},{-3,-2},{-4,-3}};
pattern1[1]={{-1,-1},{-2,-2},{-3,-3},{-4,-4}};
pattern1[2]={{0,-1},{-1,-2},{-2,-3},{-3,-4}};
pattern1[3]={{0,-1},{0,-2},{-1,-3},{-2,-4}};
pattern1[4]={{0,-1},{0,-2},{0,-3},{-1,-4}};
pattern1[5]={{0,-1},{0,-2},{0,-3},{0,-4}};
pattern1[6]={{0,-1},{0,-2},{0,-3},{1,-4}};
pattern1[7]={{0,-1},{0,-2},{1,-3},{2,-4}};
pattern1[8]={{0,-1},{1,-2},{2,-3},{3,-4}};
pattern1[9]={{1,-1},{2,-2},{3,-3},{4,-4}};
pattern1[10]={{1,0},{2,-1},{3,-2},{4,-3}};
pattern2[0]={{-1,-1},{-1,-2},{-1,-3},{-1,-4}};
pattern2[1]={{0,-1},{0,-2},{0,-3},{0,-4}};
pattern2[2]={{1,-1},{1,-2},{1,-3},{1,-4}};
pattern2[3]={{1,-1},{2,-2},{2,-3},{2,-4}};
pattern2[4]={{1,-1},{2,-2},{3,-3},{3,-4}};
pattern2[5]={{1,-1},{2,-2},{3,-3},{4,-4}};
pattern2[6]={{1,-1},{2,-2},{3,-3},{4,-3}};
pattern2[7]={{1,-1},{2,-2},{3,-2},{4,-2}};
pattern2[8]={{1,-1},{2,-1},{3,-1},{4,-1}};
pattern2[9]={{1,0},{2,0},{3,0},{4,0}};
pattern2[10]={{1,1},{2,1},{3,1},{4,1}};
However i am getting compiler errors!?! Is this the correct way to assign values or am i waaay off??