-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path3darray.cpp
59 lines (56 loc) · 1.15 KB
/
3darray.cpp
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
53
54
55
56
57
58
59
/*
* DYNAMIC 3D ARRAY
*/
#include <iostream>
using namespace std;
int main()
{
cout << "Enter the rows cols and height of the 3d array" << endl;
int rows;
int cols;
int height;
cin >> rows >> cols >> height;
int ***arr;
arr = new int**[height];
for(int i=0;i<rows;i++)
{
arr[i] = new int*[rows];
for(int j=0;j<cols;j++)
{
arr[i][j] = new int[cols];
}
}
cout << "Enter the element of the array" << endl;
for(int i=0;i<height;i++)
{
for(int j=0;j<rows;j++)
{
for(int k=0;k<cols;k++)
{
cin >> arr[i][j][k];
}
}
}
cout << "Entered elements of the array" << endl;
for(int i=0;i<height;i++)
{
for(int j=0;j<rows;j++)
{
for(int k=0;k<cols;k++)
{
cout << arr[i][j][k] << " ";
}
cout << endl;
}
cout << "----------"<<endl;
}
for(int i=0;i<rows;i++)
{
for(int j=0;j<cols;j++)
{
delete [] arr[i][j];
}
delete [] arr[i];
}
delete [] arr;
}