二维数组的定义有四种方法:
#include <iostream>
using namespace std;
int main()
{
int arr1[3][4];//第一种类型的使用
arr1[0][0] = 1;
arr1[0][1] = 2;
arr1[0][2] = 3;
arr1[0][3] = 4;
arr1[1][0] = 5;
arr1[1][1] = 6;
arr1[1][2] = 7;
arr1[1][3] = 8;
arr1[2][0] = 9;
arr1[2][1] = 10;
arr1[2][2] = 11;
arr1[2][3] = 12;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 4; j++ )
{
cout << arr1[i][j] << endl;;
}
}
system("pause");
}
#include <iostream>
using namespace std;
int main()
{
int arr1[3][4] =
{
{1,2,3,4},
{5,6,7,8},
{9,10,11,12}
};//第二种类型的使用
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 4; j++ )
{
cout << arr1[i][j] << e