-
Notifications
You must be signed in to change notification settings - Fork 8
/
close.cpp
42 lines (34 loc) · 933 Bytes
/
close.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <cmath>
using namespace std;
class Point1 {
friend float dist(const Point1&,const Point1&);
friend void close(Point1 *,Point2 *,Point2 *,int,int,Point1&,Point1&,float&);
friend bool closest(Point1 *,int,Point&,Point1&,float &);
friend void main();
public:
int operator <= (Point1 a) const
{return (x <= a.x);}
private:
int ID;
float x,y;
};
class Point2 {
friend float dist(const Point2&,const Point2&);
friend void close(Point1 *,Point2 *,Point2 *,int,int,Point1&,Point1&,float&);
friend bool closest(Point1 *,int,Point1&,Point1&,float &);
friend void main();
public:
int operator <= (Point2 a) const
{return (y <= a.y);}
private:
int p;
float x,y;
};
template<class T>
inline float dist(const T& u,const T& v)
{
float dx=u.x-v.x;
float dy=u.y-v.y;
return sqrt(dx*dx+dy*dy);
}