#include "stdafx.h"
#include
using namespace std;
int main()
{
int r; //行数
int c; //列数
cout<<"Please input the number of rows of the dynamic array: ";
cin>>r; //输入行数
cout<<"Please input the number of columns of the dynamic array: ";
cin>>c; //输入列数
//创建二维动态数组
int **p=new int*[r];
for(int i=0;i
{
p[i]=new int[r];
}
cout<<"The array named p["<
//循环赋值
int temp;
for(int i=0;i
{
for(int j=0;j
{
cout<<"Please input a value of p["<
cin>>temp;
*(*(p+i)+j)=temp; //寻址赋值
}
}
//循环显示
cout<<"The dynamic array is "<
for(int i=0;i
{
for(int j=0;j
{
cout<<*(*(p+i)+j)<<" "; //寻址读取
}
cout<
}
return 0;
}
编辑特别推荐: