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