-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path3darrays.cpp
51 lines (47 loc) · 1.1 KB
/
3darrays.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
/*
* 3 DIMENSIONAL ARRAYS
*/
#include <iostream>
using namespace std;
int main()
{
int length;
int breadth;
int height;
cout << "Enter length,breadth and height of the 3d array"<<endl;
cin >> length >> breadth >> height;
//declaring 3d array
int arr[height][length][breadth];
cout << "Enter the elements of 3d arrays" << endl;
for(int i=0;i<height;i++)
{
cout << "For height "<< i<<endl;
cout << "Enter 2d array"<<endl;
for(int j=0;j<length;j++)
{
for(int k=0;k<breadth;k++)
{
cin >> arr[i][j][k];
}
}
}
cout << "Entered 3d array" << endl;
for(int i=0;i<height;i++)
{
for(int j=0;j<length;j++)
{
for(int k=0;k<breadth;k++)
{
if(k==breadth-1)
{
cout << arr[i][j][k] <<endl;
}
else
{
cout << arr[i][j][k] <<" ";
}
}
}
cout << "==========="<<endl;
}
}