c 二维数组指针
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
int a[3][3];
for (int i = 0; i != 3; i++)
{
for (int j = 0; j != 3; j++)
{
a[i][j] = i * 3 + j;
}
}
for (int i = 0; i != 3; i++)
{
for (int j = 0; j != 3; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
int (*p)[3] = a;
cout << (*p)[0] << endl;
cout << (*p)[1] << endl;
cout << *p[0] << endl;
cout << *p[1] << endl;
return 0;
}
答案:
0 1 2
3 4 5
6 7 8
0
1
0
3