C/C++ 中的多維陣列的初始化
在多維陣列中,陣列應具有超過 1 的維度。下圖顯示了具有維度 3 x 3 x 3 的多維陣列的記憶體分配策略。

這是一個 C++ 程式,用於初始化多維陣列。
演算法
Begin Initialize the elements of a multidimensional array. Print the size of the array. Display the content of the array. End
示例
#include<iostream>
using namespace std;
int main()
{
int r, c;
int a[][2] = {{3,1},{7,6}};
cout<< "Size of the Array:"<<sizeof(a)<<"\n";
cout<< "Content of the Array:"<<sizeof(a)<<"\n";
for(r=0; r<2; r++) {
for(c=0; c<2; c++) {
cout << " " << a[r][c];
}
cout << "\n";
}
return 0;
}輸出
Size of the Array:16 Content of the Array:16 3 1 7 6
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP