+ 2

Using C++ give me an example of 3D Arrays Not available in sololearn course?

Using c++

9th Dec 2018, 6:26 AM
Saad Saleem
Saad Saleem - avatar
6 Respuestas
+ 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/
9th Dec 2018, 6:42 AM
Babak
Babak - avatar
+ 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.
10th Dec 2018, 1:59 AM
Germain F
Germain F - avatar
+ 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; }
9th Dec 2018, 6:48 AM
Saad Saleem
Saad Saleem - avatar
+ 1
I Get this code from upper website
9th Dec 2018, 6:50 AM
Saad Saleem
Saad Saleem - avatar
+ 1
Excellent Saad Mughal 8D
9th Dec 2018, 7:44 AM
Babak
Babak - avatar
+ 1
Thanks soldier
9th Dec 2018, 8:22 AM
Saad Saleem
Saad Saleem - avatar