# ZASHTO NE RABOTISH VO C++>???

Mar 11th, 2020 (edited)
143
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include<iostream>
2. #include<math.h>
3. using namespace std;
4. typedef struct point2D {
5.     double x;
6.     double y;
7. }
8. point2D;
9.
10. float distance2D ( point2D t1, point2D t2) {
11.     return sqrt((t1.x-t2.x)*(t1.x-t2.x)+(t1.y-t2.y)*(t1.y-t2.y));
12. }
13.
14. typedef struct point3D {
15.     double x;
16.     double y;
17.     double z;
18.
19. }
20. point3D;
21.
22. float distance3D (point3D t1, point3D t2) {
23.
24.     return sqrt ((t1.x-t2.x)*(t1.x-t2.x)+(t1.y-t2.y)*(t1.y-t2.y)+(t1.z-t2.z)*(t1.z-t2.z));
25.
26. }
27.
28. int is_collinear(point2D t1, point2D t2, point2D t3) {
29.     if((t2.y-t1.y)/(t2.x-t1.x)==(t3.y-t2.y)/(t3.x-t2.x))
30.         return 1;
31.     else
32.         return 0;
33.
34. }
35.
36. int main () {
37.     float x1, y1, x2, y2;
38.
39.     cin>>x1,y1;
40.
41.     cin>>x2,y2;
42.
43.     point2D t1 = {x1, y1};
44.     point2D t2 = {x2, y2} ;
45.
46.     cout<<distance2D(t1,t2)<<'\n';
47.
48.     float z1, z2;
49.
50.     cin>>z1,z2;
51.
52.     point3D t3 = {x1,y1,z1};
53.     point3D t4 = {x2,y2,z2};
54.
55.     cout<<distance3D(t3,t4)<<'\n';
56.
57.     point2D t5= {z1,z2};
58.
59.     cout<<is_collinear(t1,t2,t5);
60.
61.     return 0;
62. }
RAW Paste Data