#include<iostream>
using namespace std;
const int X=2;
const int Y=5;
const int Z=2;
//二维数组的单循环输出
void Show2()
{
int a[X][Y]={1,2,3,4,5,6,7,8,9,0};
int S=X*Y;
for(int i=0;i<S;i++)
cout<<a[i/Y][i%Y]<<" ";
cout<<endl;
}
//三位数组的单循环输出
void Show3()
{
int a[X][Y][Z]={1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0};
for(int j=0;j<X*Y*Z;j++)
cout<<a[j/(Y*Z)][(j/Z)%Y][j%Z]<<" ";
cout<<endl;
}
int main()
{
Show2();
cout<<endl<<endl;
Show3();
cout<<endl<<endl;
system("pause");
return 0;
using namespace std;
const int X=2;
const int Y=5;
const int Z=2;
//二维数组的单循环输出
void Show2()
{
int a[X][Y]={1,2,3,4,5,6,7,8,9,0};
int S=X*Y;
for(int i=0;i<S;i++)
cout<<a[i/Y][i%Y]<<" ";
cout<<endl;
}
//三位数组的单循环输出
void Show3()
{
int a[X][Y][Z]={1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0};
for(int j=0;j<X*Y*Z;j++)
cout<<a[j/(Y*Z)][(j/Z)%Y][j%Z]<<" ";
cout<<endl;
}
int main()
{
Show2();
cout<<endl<<endl;
Show3();
cout<<endl<<endl;
system("pause");
return 0;
}
结果见下图中!!!