【C++】数组
时间:2010-10-30 来源:K#
#include<stdio.h>
void print(int (*pa)[4], int m, int n)
{
for(int i=0; i<m; i++)
{
for(int j=0; j<n; j++)
{
printf("%d\t", pa[i][j]);
}
printf("\n");
}
}
int main()
{
int a1[12] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
int a2[3][4] = {{ 0, 1, 2, 3 },
{ 4, 5, 6, 7 },
{ 8, 9, 10, 11}};
int (*pa1)[4] = &a1;
int (*pa2)[4] = &a2;
print(pa1, 3, 4);
printf("\n");
print(pa2, 3, 4);
}
相关阅读 更多 +