Guest User

Untitled

a guest
Jan 18th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. class CPoint{
  6. public:
  7. double x;
  8. double y;
  9. // CPoint(){}
  10. CPoint(int x1,int y1){
  11. x = x1;
  12. y = y1;
  13. }
  14. double operator -(CPoint & A)const{
  15. return sqrt(pow(x - A.x ,2) + pow(y - A.y , 2));
  16. }
  17. };
  18.  
  19. int main (){
  20. int x1 , x2, y1, y2;
  21. cout <<"请依次输入两点坐标:"<<endl;
  22. cin >> x1 >>y1 >>x2 >>y2;
  23. CPoint p1(x1 , y1), p2( x2, y2);
  24. cout <<"两点距离:" <<p1-p2<<endl;
  25. return 0;
  26. }
Add Comment
Please, Sign In to add comment