What's the syntax? For example, a 2d array:
I'm looking for a similar approach with a 3D array but can't seem to find it anywhere.Code:int[][] array = { {2, 5} , {7, 4}, };
What's the syntax? For example, a 2d array:
I'm looking for a similar approach with a 3D array but can't seem to find it anywhere.Code:int[][] array = { {2, 5} , {7, 4}, };
Well, there are a few things wrong with your code:
1) It does not work.
2) It does not work.
3) It does not work.
Hope this helps.
same way, but it starts to get messy and hard to follow...
Code:int array [2][2][2]= { { {1,1}, {1,2} },{ {2,1}, {2,2} } };
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT
yeah 3d arrays are pain in the ars. What are you trying to do with them funkydude?
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka
I'm making Tetris, I need a 3d array to represent each block and it's rotations. I realize I could of just calculated the rotation myself using just a 2d array also, but I decided to go this way.Originally posted by axon
yeah 3d arrays are pain in the ars. What are you trying to do with them funkydude?
Well, there are a few things wrong with your code:
1) It does not work.
2) It does not work.
3) It does not work.
Hope this helps.
a 3d array is the hard way of going about it dude. Do it in 2d and figure out the rotation there. If you're having troubles do a search....this has been done many times here before.
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka
Also, remember that in memory, the data is laid out just as it would be if it were a one-dimensional array. You can see this for yourself by simply casting the base of the array to a pointer of the appropriate type:
Code:const int X = 4, Y = 2, Z = 5; int abc[X][Y][Z] = { { { 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 10 } }, { {11, 12, 13, 14, 15 }, {16, 17, 18, 19, 20 } }, { {21, 22, 23, 24, 25 }, {26, 27, 28, 29, 30 } }, { {31, 32, 33, 34, 35 }, {36, 37, 38, 39, 40 } } }; int main() { for(int x = 0; x < X; ++x) for(int y = 0; y < Y; ++y) for(int z = 0; z < Z; ++z) printf("%d...", abc[x][y][z]); const int U = X * Y * Z; int * r = (int*)abc; printf("\n\n - again - \n\n"); for(int u = 0; u < U; ++u) printf("%d...", r[u]); return 0; }
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }