#include
using namespace std;
int ia[3][4]={
1,3,2,4,5,11,9,7,8,10,6,12};
int main()
{
for(const int (&row) [4] : ia)
for(const int col : row)
cout<<col<<" ";
return 0;
}
版本二:
#include
using namespace std;
int ia[3][4]={
1,3,2,4,5,11,9,7,8,10,6,12};
int main()
{
for(int i=0;i<3;i++)
for(int j=0;j<4;j++)
cout<<ia[i][j]<<" ";
return 0;
}
版本三:
#include
using namespace std;
int ia[3][4]={
1,3,2,4,5,11,9,7,8,10,6,12};
int main()
{
for(int(*p) [4] = begin(ia);p!=end(ia);p++)
for(int* q= begin(*p);q!=end(*p);q++)
cout<<*q<<" ";
return 0;
}
#include
using namespace std;
using int_array = int [4];
//typedef int int_array [4];//两种写法我推荐使用的一种
int ia[3][4] = {
1, 3, 2, 4, 5, 11, 9, 7, 8, 10, 6, 12};
int main()
{
for (int_array *p = begin(ia); p != end(ia); p++)
for (int *q = begin(*p); q != end(*p); q++)
cout << *q << " ";
return 0;
}
#include
using namespace std;
int ia[3][4] = {
1, 3, 2, 4, 5, 11, 9, 7, 8, 10, 6, 12};
int main()
{
for (auto &row : ia)
for (auto &col : row)
cout << col <<" ";
return 0;
}