+ 2
Using C++ give me an example of 3D Arrays Not available in sololearn course?
Using c++
6 Answers
+ 7
Very interesting!
In such cases ask the trusty friend --> Google
Some result from Google search (query --> C++ 3D array example)
https://www.programiz.com/cpp-programming/multidimensional-arrays
https://www.geeksforgeeks.org/multidimensional-arrays-c-cpp/
+ 2
int Eg[2][2][2] = {
{ {0,1}, {3,0} },
{ {4,-2}, {5,1} }
};
Or
vector< vector< vector<int> > > vvv;
vector<int> v1 = {2,4,6};
vecor<int> v2 = {1,3,5};
vector<vector<int>> vv = {v1, v2};
vvv.push_back(vv);
This may seem stressful than using raw arrays, but creating a flexible class will make your dream come through.
+ 1
include<iostream>
using namespace std;
int main()
{
// initializing the 3-dimensional array
int x[2][3][2] =
{
{ {0,1}, {2,3}, {4,5} },
{ {6,7}, {8,9}, {10,11} }
};
// output each element's value
for (int i = 0; i < 2; ++i)
{
for (int j = 0; j < 3; ++j)
{
for (int k = 0; k < 2; ++k)
{
cout << "Element at x[" << i << "][" << j
<< "][" << k << "] = " << x[i][j][k]
<< endl;
}
}
}
return 0;
}
+ 1
I Get this code from upper website
+ 1
Excellent Saad Mughal 8D
+ 1
Thanks soldier