Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class punct {
- private:
- int x,y;
- public :
- friend double dist(punct &p1, punct &p2);
- punct (int a , int b)
- {
- x=a;
- y=b;
- }
- };
- double dist (punct &p1, punct & p2)
- {
- return (sqrt(p1.x-p2.x)*(p1.x-p2.x) +(p1.y-p2.y)*(p1.y-p2.y));
- }
- int main()
- {
- punct p1(3,3);
- punct p2(1,7);
- cout<<"d(p1,p2)=";
- cout<<dist(p1,p2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement