code_junkie

c++ 3d arrays

Nov 12th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7. int myArray[10][10][10];
  8.  
  9. for (int i = 0; i <= 9; ++i){
  10. for (int t = 0; t <=9; ++t){
  11. for (int x = 0; x <= 9; ++t){
  12.  
  13. myArray[i][t][x] = i+t+x;
  14.  
  15. }
  16.  
  17. }
  18.  
  19. }
  20.  
  21.  
  22. for (int i = 0; i <= 9; ++i){
  23. for (int t = 0; t <=9; ++t){
  24. for (int x = 0; x <= 9; ++t){
  25.  
  26. cout << myArray[i][t][x] << endl;
  27.  
  28. }
  29.  
  30. }
  31.  
  32. }
  33.  
  34. system("pause");
  35.  
  36. }
  37.  
  38. for (int x = 0; x <= 9; ++t){
  39.  
  40. for (int x = 0; x <= 9; ++x){
  41.  
  42. const std::size_t ARRAY_SIZE = 10;
  43.  
  44. int myArray[ARRAY_SIZE][ARRAY_SIZE][ARRAY_SIZE];
  45.  
  46. for (std::size_t i = 0; i < ARRAY_SIZE; ++i)
  47. {
  48. for (std::size_t j = 0; j < ARRAY_SIZE; ++j)
  49. {
  50. for (std::size_t k = 0; k < ARRAY_SIZE; ++k)
  51. {
  52. std::assert (i < ARRAY_SIZE && j < ARRAY_SIZE && k < ARRAY_SIZE);
  53. // Do stuff
  54. }
  55. }
  56. }
Add Comment
Please, Sign In to add comment