二维数组的定义方法:
二维数组的初始化方法:
二维数组的使用方法:
实例:月份转换程序
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
char month[12][10]={"January","February","March","April","May","June",
"July","August","September","October","November","December"};
int m;
cin>>m;
if(m>0&&m<13){
cout<<month[m-1];
}else{
cout<<"the month is wrong!"<<endl;
}
return 0;
}
多维数组:
int A[5][4][3]理解为5层4行3列,存储数据时先存储第一层,再第二层,第三层... 每一层中,先存储第一行第一列,再第一行第二列,再第一行第三列。然后第二行...