一個 3x3x3 的三維陣列, 總共可儲存 27 筆資- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int a[3][3][3]={{{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}}};
- for(int i=0; i<=2; i++)
- {
- for(int j=0; j<=2; j++)
- {
- for(int k=0; k<=2; k++)
- {
- cout<<"a["<<i<<"]["<<j<<"]["<<k<<"]="<<a[i][j][k]<<endl;
- }
- }
- }
- system("pause");
- return 0;
- }
複製代碼 料. |