二维数组动态申请内存,和 删除二维数组内存

int** copyPath =new int*[rows];
for (int i = 0; i < rows; i++)
{
copyPath[i] = new int[cols];
}


for (int i = 0; i < rows; i++)
{
delete[] copyPath[i];
}
delete[] copyPath;


/////直接声明的方式
int arrPath[4][4] = { { 1, 3, 5, 9 }, { 8, 1, 3, 4 }, { 5, 0, 6, 1 }, { 8, 8, 4, 0 } };

猜你喜欢

转载自www.cnblogs.com/music-liang/p/12813396.html