#include<stdio.h>
#include<stdlib.h>
int main()
{
//int arr[3][4]
//
int row;
int col;
scanf_s("%d%d", &row, &col);
int **q = (int **)malloc(sizeof(int)* row);//开辟一块空间 存储一个含有row数组指针的数组
q[0] = (int *)malloc(sizeof(int)*col);
for (int i = 1; i < row;i++)
{
q[i] = q[0] + i;//q[0]为 0000首元素地址//数组指针。+1z
}//jia
int j = 0;
int k = 0;
for (j = 0; j < row; j++)
{
for (k = 0; k < col; k++)
{
q[j][k] = j*k + k;
printf("%d ", q[j][k]);
}
}
system("pause");
return 0;
}
动态开辟有序二维数组
时间: 2024-10-10 21:20:15