WoW!
#include <iostream>
int main(void){
int i=6,j=5,k=4;
int ****threeDimensionArr;// 4 stars! for 3D
threeDimensionArr = new int ***[i];
for(int i_i=0; i_i<i; ++i_i){
threeDimensionArr[i_i] = new int **[j];
for(int j_i=0; j_i<j; ++j_i){
threeDimensionArr[i_i][j_i] = new int *[k];
for(int k_i=0; k_i<k; ++k_i){
threeDimensionArr[i_i][j_i][k_i]
= new int(i_i*j_i*k_i);
std::cout
<< *threeDimensionArr[i_i][j_i][k_i]<<"\t";
}
std::cout << std::endl;
}
std::cout << std::endl;
}
//free memory
for(int i_i=0; i_i<i; ++i_i){
for(int j_i=0; j_i<j; ++j_i){
for(int k_i=0; k_i<k; ++k_i){
delete threeDimensionArr[i_i][j_i][k_i];
}
delete [] threeDimensionArr[i_i][j_i];
}
delete [] threeDimensionArr[i_i];
}
}
No comments:
Post a Comment