-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamic-4darray.cpp
More file actions
52 lines (43 loc) · 1.18 KB
/
dynamic-4darray.cpp
File metadata and controls
52 lines (43 loc) · 1.18 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
#include <bits/stdc++.h>
using namespace std;
void print_4darray(int**** arr4d, int dist, int height, int rows, int cols){
for(int d=0;d<dist;d++){
for(int h=0;h<height;h++){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cout<<arr4d[d][h][i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
}
cout<<endl;
}
cout<<endl;
}
int main(){
int dist, height, rows, cols;
cin>>dist>>height>>rows>>cols;
int**** arr4d = new int***[dist];
for(int d=0;d<dist;d++){
int*** arr3d = new int**[height];
for(int i=0;i<height;i++){
int** arr2d = new int*[rows];
for(int j=0;j<rows;j++){
arr2d[j] = new int[cols];
}
arr3d[i] = arr2d;
}
arr4d[d] = arr3d;
}
for(int d=0;d<dist;d++){
for(int h=0;h<height;h++){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>arr4d[d][h][i][j];
}
}
}
}
print_4darray(arr4d, dist, height, rows, cols);
}