Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- class CPoint{
- public:
- double x;
- double y;
- // CPoint(){}
- CPoint(int x1,int y1){
- x = x1;
- y = y1;
- }
- double operator -(CPoint & A)const{
- return sqrt(pow(x - A.x ,2) + pow(y - A.y , 2));
- }
- };
- int main (){
- int x1 , x2, y1, y2;
- cout <<"请依次输入两点坐标:"<<endl;
- cin >> x1 >>y1 >>x2 >>y2;
- CPoint p1(x1 , y1), p2( x2, y2);
- cout <<"两点距离:" <<p1-p2<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment