1 #include2 #include 3 #include 4 using namespace std; 5 6 //动态申请内存,实现一维数组 7 void oneDimensionalArray(int n) 8 { 9 int *num = new int(n);10 srand(time(NULL));11 for(int i = 0; i < n;i++)12 {13 num[i] = rand()%100;14 }15 16 for(int i = 0; i < n;i++)17 {18 cout< <<" ";19 }20 21 delete []num; //记得删除22 num = NULL;23 cout< >num;74 oneDimensionalArray(num);75 76 77 //动态实现二维数组78 int row, low;79 cin>>row>>low;80 twoDimensionalArray(row, low);81 82 return 0;83 }