File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < cmath>
3
+ using namespace std ;
4
+ class points
5
+ {
6
+ float i ,j;
7
+ float dis;
8
+ public :
9
+ points ()
10
+ {
11
+ cout<<" Enter the x and y components " <<endl;
12
+ cin>>i>>j;
13
+ }
14
+ float nearest (class points X, class points Y)
15
+ {
16
+ dis=sqrt ((X.i -Y.i )*(X.i -Y.i )+(X.j -Y.j )*(X.j -Y.j ));
17
+ return dis;
18
+ }
19
+ };
20
+ int main ()
21
+ { int i ,j ;
22
+ cout<<" \n WELCOME !! \n Enter for the nearest points A , B ,C respectively : " <<endl;
23
+ class points A , B ,C ;
24
+ cout<<" Now enter for the central point : " <<endl;
25
+ class points central_point;
26
+ float dis1=A.nearest (A,central_point);
27
+ float dis2=B.nearest (B,central_point);
28
+ float dis3=C.nearest (C,central_point);
29
+ cout<<" Distance between point A and central point is : " <<dis1<<endl;
30
+ cout<<" Distance between point B and central point is : " <<dis2<<endl;
31
+ cout<<" Distance between point C and central point is : " <<dis3<<endl;
32
+ if (dis1==dis2 && dis2==dis3 && dis1==dis3)
33
+ {
34
+ cout<<" All are at same distance " <<dis1<<endl;
35
+ }
36
+ else {
37
+ float a[3 ]={ dis1 , dis2 , dis3 }; float temp ;
38
+ for (i=0 ;i<3 ;i++)
39
+ {
40
+ for (j=0 ;j<3 -i;j++)
41
+ {
42
+ if (a[j]>a[i])
43
+ {
44
+ temp=a[i];
45
+ }
46
+ }
47
+ }
48
+ cout<<" " <<temp<<" : is the nearest distance . " <<endl;
49
+ if (dis1==dis2){ cout<< " Point A and B are at same distance . " <<endl;}
50
+ if (dis2==dis3){ cout<< " Point C and B are at same distance . " <<endl;}
51
+ if (dis3==dis1){ cout<< " Point A and C are at same distance . " <<endl;}
52
+
53
+ }
54
+ return 0 ;
55
+
56
+ }
You can’t perform that action at this time.
0 commit comments