1 int **arr_matrix = new int*[n]; 2 for(i = 0; i < n; ++i) arr_matrix[i] = new int[n]; 3 //内容 4 for(i = 0; i < n; ++i) delete [] arr_matrix[i]; 5 delete [] arr_matrix;
模板:使用new delete 创建二维数组
时间: 2024-11-10 07:07:03
1 int **arr_matrix = new int*[n]; 2 for(i = 0; i < n; ++i) arr_matrix[i] = new int[n]; 3 //内容 4 for(i = 0; i < n; ++i) delete [] arr_matrix[i]; 5 delete [] arr_matrix;
模板:使用new delete 创建二维数组