#include<iostream> using namespace std; int main(void) { int rows = 6;//6行 int cols = 8;//8列 //开辟内存指向每一行,每一行都是一个一维数组 int** arr = new int* [rows]; //为每一行开辟内存 for (int i = 0; i < rows; i++) { arr[i] = new int[cols]; } //为二维数组赋初值 for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { arr[i][j] = 0; } } //释放内存 delete[]arr; return 0; }