//第一种方法
int **a;
int i;
a = (int **)malloc(sizeof(int *) * 10);
for (i = 0; i<10; i++)
a[i] = (int *)malloc(sizeof(int) * 5);
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 5; j++)
{
//*(*(a + i) + j) = i;
a[i][j] = i;
}
}
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 5; j++)
{
//printf("%2d", *(*(a + i) + j));
printf("%4d", a[i][j]);
}
printf("\n");
}
//第二种方法
int(*a)[5];
a = (int(*)[5]) malloc(sizeof(int) * 10 * 5);
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 5; j++)
{
//*(*(a + i) + j) = i;
a[i][j] = i;
}
}
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 5; j++)
{
//printf("%2d", *(*(a + i) + j));
printf("%4d", a[i][j]);
}
printf("\n");
}