作者在 2009-05-07 23:00:09 发布以下内容
定义一个点类 计算两点之间的距离 是2维的
如果我问白痴的问题 希望大家不要介意
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdio.h>
#include<math.h>
using namespace std;
class point
{int x,y;
public:
void set(int a,int b){x=a;y=b;}
void distance(point a,point b);
};
void point::distance(point a,point b)
{point a;
point b;
double s;
s=sqr((a.x -b.x )*(a.x -b.x )+(a.y -b.y)*( a.y -b.y));
cout<<s;
class point
{int x,y;
public:
void set(int a,int b){x=a;y=b;}
void distance(point a,point b);
};
void point::distance(point a,point b)
{point a;
point b;
double s;
s=sqr((a.x -b.x )*(a.x -b.x )+(a.y -b.y)*( a.y -b.y));
cout<<s;
}
void main()
{point a,b;
a.set (3,1);
b.set (2,1);
(a,b).distance ();
}