#include<iostream>
using namespace std;
int main()
{
int n=2, m=3;
int **arry2d = new int *[n];//定义行指针,也就是一个数组指针,元素为两个指针
for (int i = 0; i < n; ++i)//为每个指针各分配元素为三的行数组空间
{
arry2d[i] = new int[m];
}
for (int i = 0; i < 2; ++i)//测试,给二维数组赋值
{
for (int j = 0; j < 3; ++j)
{
arry2d[i][j] = i + j;
}
}
for (int i = 0; i < 2; ++i)//输出看看
{
for (int j = 0; j < 3; ++j)
{
cout << arry2d[i][j]<<"\t" ;
if (j == 2)
{
cout << endl;
}
}
}
for (int i = 0; i < 2; ++i)//先删除行数组空间
{
delete[]arry2d[i];
}
delete[]arry2d;//删除指针数组
system("pause");
return 0;
}
using namespace std;
int main()
{
int n=2, m=3;
int **arry2d = new int *[n];//定义行指针,也就是一个数组指针,元素为两个指针
for (int i = 0; i < n; ++i)//为每个指针各分配元素为三的行数组空间
{
arry2d[i] = new int[m];
}
for (int i = 0; i < 2; ++i)//测试,给二维数组赋值
{
for (int j = 0; j < 3; ++j)
{
arry2d[i][j] = i + j;
}
}
for (int i = 0; i < 2; ++i)//输出看看
{
for (int j = 0; j < 3; ++j)
{
cout << arry2d[i][j]<<"\t" ;
if (j == 2)
{
cout << endl;
}
}
}
for (int i = 0; i < 2; ++i)//先删除行数组空间
{
delete[]arry2d[i];
}
delete[]arry2d;//删除指针数组
system("pause");
return 0;
}