题解 | #创建二维动态数组#
创建二维动态数组
https://www.nowcoder.com/practice/9e55995c4e5345878a31682e4048a0ed
int ** p = new int* [n]; for (int i = 0; i < n; ++i) { p[i] = new int[n]; for (int j = 0; j < n; ++j) { p[i][j] = i + j; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cout << p[i][j] << " "; } cout << endl; }二维数组就是指向一维数组的指针, 即指向指针数组的指针.