Advertisement
Guest User

Untitled

a guest
May 21st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. class punct {
  5. private:
  6. int x,y;
  7.  
  8. public :
  9. friend double dist(punct &p1, punct &p2);
  10. punct (int a , int b)
  11. {
  12.  
  13. x=a;
  14. y=b;
  15. }
  16. };
  17. double dist (punct &p1, punct & p2)
  18. {
  19. return (sqrt(p1.x-p2.x)*(p1.x-p2.x) +(p1.y-p2.y)*(p1.y-p2.y));
  20. }
  21. int main()
  22. {
  23. punct p1(3,3);
  24. punct p2(1,7);
  25. cout<<"d(p1,p2)=";
  26. cout<<dist(p1,p2);
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement