1、/动态定义一维数组、二维数组、三维数组#include#includeusing namespace std ;int main()int hight , row , col ;register int i , j , k ;srand(unsigned)time(NULL) ;coutrow ;/动态定义一维数组int *p1 ; p1 = new int row ;/输入一维数组的值for( i = 0 ; i row col ;/动态定义二维数组int *p2 ;p2 = new int*row ;for( i = 0 ; i hightrow col ;/动态定义三维数组:int *
2、p3 ;p3 = new int*hight ;for( i = 0 ; i hight ; i + ) p3i = new int*row ;for( i = 0 ; i hight ; i + ) for( j = 0 ; j row ; j + ) p3ij = new intcol ;/输入三维数组值:for(i = 0 ; i hight ; i + )for(j = 0 ; j row ; j + )for( k = 0 ; k col ; k +)p3ijk = rand()%10 ;/输出三维数组:cout“输出三维数组“endl;for(i = 0 ; i hight ; i + ) for( j = 0 ; j row ; j + ) for( k = 0 ; k col ; k + )coutp3ijk' ' ;coutendl;coutendl;/释放三维数组for( i = 0 ; i hight ; i + )for( j = 0 ; j row ; j + )delete p3ij ;for( i = 0 ; i hight ; i + )delete p3i ;delete p3 ;return 0 ;