c++ 利用new动态的定义二维数组
#include <iostream> using namespace std; int main() { int row = 4, col = 5; // key code: 申请空间 int **edge = (int **) new int *[row]; for (int i = 0; i < row; i++) { edge[i] = new int[col]; } for (int i = 0; i < row; i++) { cout << endl; for (int j = 0; j < col; j++) { edge[i][j] = rand()%100; cout << edge[i][j] << " "; } } return 0; }
posted on 2018-03-01 21:45 HelloShijam 阅读(6986) 评论(0) 编辑 收藏 举报