-求解救!我在庞果英雄会被这道题
/***************************/ /* DYNAMIC ARRAY EXEMPLE */ /* 唐国峰2011年月日 */
/***************************/
//按照动态二维数组的申请、赋初值、使用、释放空间五个部分给出代码,以示参考。 //同时,给出了动态二维数组用作形参和实参的实例,方便大家查询。
#include using namespace std;
//动态二维数组作形参
void display(int ** &p,int row,int col) { int i,j; for(i = 0;...全部
/***************************/ /* DYNAMIC ARRAY EXEMPLE */ /* 唐国峰2011年月日 */
/***************************/
//按照动态二维数组的申请、赋初值、使用、释放空间五个部分给出代码,以示参考。
//同时,给出了动态二维数组用作形参和实参的实例,方便大家查询。
#include using namespace std;
//动态二维数组作形参
void display(int ** &p,int row,int col) { int i,j; for(i = 0;i > row >> col; cout << endl; p = new int *[row]; for(int i = 0;i <= row-1;i++) { p[i]=new int[col]; } //为动态二维数组p的元素赋初值 for(i = 0;i <= row-1;i++) { for(j = 0; j <= col-1;j++)
{ p[i][j] = 0; } } //动态二维数组p的使用举例 for(i = 0;i <= row-1;i++) { for(j = 0; j <= col-1;j++) { cout << p[i][j] << "\t"; } cout << endl; } cout << endl; cout << "通过调用函数输出:" << endl << endl; //动态二维数组p作为参数 display(p,row,col); //释放资源时先将里面的元素删掉再删除p for(i = 0;i <= row-1;i++) { delete [] p[i]; } delete p; //-------格式化输出模板信息内容------开始------ cout << endl << endl; system("pause");。收起