# include
# include
using namespace std;
class point
{
private:
double x,y;
public:
point(double a=0,double b=0);
double getx()
{return x;};
double gety()
{return y;};
void setxy(double,double);
~point();
};
point::point(double a,double b)
{x=a;y=b;}
void point::setxy(double a,double b)
{x=a;y=b;}
point::~point()
{cout<<"delete it:"<
void set(point *);
void display(point *);
double lenth(point *);
int main()
{
point *p=new point[10];
if(p==NULL)
{
cout<<"地址申请失败,结束程序运行。\n";
return 0;
}
set(p);
cout<<"内存块的数据如下:"<
cout<<"组成的折现长度为:";
cout<
system("pause");
return 0;
}
void set(point *p)
{
double a,b;
for(int i=0;i
cout<<"输入第"< cin>>a>>b;
(p+i)->setxy(a,b);
}
}
void display(point *p)
{
for(int i=0;i
double lenth(point *p)
{
double sum=0,a1,a2,b1,b2;
a1=p->getx();
b1=p->gety();
for(int i=1;i
a2=(p+i)->getx();
b2=(p+i)->gety();
sum+=sqrt((a1-a2)*(a1-a2)+(b1-b2)*(b1-b2));
a1=a2;b1=b2;
}
return sum;
}