#include<iostream.h>
#include<math.h>
class Point
{
private:
int x[10];//横坐标
int y[10];//纵坐标
public:
void display();
void set();
float lenth();//求得两点之间的距离
Point();
~Point();
};
void Point::display()
{
int i=0;
for(i=0;i<10;i++)
cout << x[i] <<","<<y[i]<< endl;
}
/*void Point::set()
{
Point();
}*/
float Point::lenth()//
{
float sum=0;
int i;
for(i=0;i<9;i++)
sum=(float)sqrt((x[i]-x[i+1])*(x[i]-x[i+1])+(y[i]-y[i+1])*(y[i]-y[i+1]));
cout<<sum<<endl;
return 0.0;
}
Point::Point()
{
int i,m,n;
cout<<"input accont"<<endl;
for(i=0;i<10;i++)
{
cin>>m>>n;
x[i]=m;
y[i]=n;
}
}
Point::~Point()
{
cout<<"disconstractor"<<endl;
}
void main()
{
Point *a=new point;
// (*a).set();
(*a).display();
(*a).lenth();
}
#include<iostream>
#include<math.h>
using namespace std;
class Point
{
private:
int x[10];//横坐标
int y[10];//纵坐标
public:
void display();
void set();
float lenth();//求得两点之间的距离
Point();
~Point();
};
void Point::display()
{
int i=0;
for(i=0;i<10;i++)
cout << x[i] <<","<<y[i]<< endl;
}
/*void Point::set()
{
Point();
}*/
float Point::lenth()//
{
float sum=0;
int i;
for(i=0;i<9;i++)
sum=(float)sqrt((x[i]-x[i+1])*(x[i]-x[i+1])+(y[i]-y[i+1])*(y[i]-y[i+1]));
cout<<sum<<endl;
return 0.0;
}
Point::Point()
{
int i,m,n;
cout<<"input accont"<<endl;
for(i=0;i<10;i++)
{
cin>>m>>n;
x[i]=m;
y[i]=n;
}
}
Point::~Point()
{
cout<<"disconstractor"<<endl;
}
int main()
{
Point *a=new Point;
// (*a).set();
(*a).display();
(*a).lenth();
return 0;
}
没看你逻辑,就把语法问题给解决了。