当数组不是全局变量时:
如果数组大小是变量,则数组初始化为0时,元素的值也许不是0;
如果数组大小是常量,则数组初始化为0时,元素的值是0;
/**
当数组不是全局变量时:
如果数组大小是变量,则数组初始化为0时,元素的值也许不是0;
如果数组大小是常量,则数组初始化为0时,元素的值是0;
*/
#include <iostream>
using namespace std;
const int maxn=10;
int main()
{
cout << "数组大小是变量:\n";
cout << "输入两个值:\n";
int n, m;
cin >> n >> m;
int temp[n][m]={0};
for(int i=0;i<n;++i)
for(int j=0;j<m;++j)
cout << temp[i][j] << ' ';
cout << "\n数组大小是const 类型的常量:\n";
int matr[maxn][maxn]={0};
for(int i=0;i<maxn;++i)
for(int j=0;j<maxn;++j)
cout << matr[i][j] << ' ';
cout << "\n数组大小就是 common 常量:\n";
int a[10][10]={0};
for(int i=0;i<10;++i)
for(int j=0;j<10;++j)
cout << a[i][j] << ' ';
}