-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
60 lines (45 loc) · 1.1 KB
/
main.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include<cmath>
using namespace std;
struct Point {
double x, y;
};
double **dist_matrix(Point *a, int n);
double rast(const Point &t1, const Point &t2);
int main() {
int i, j, n;
Point *t;
double **r;
n = 4;
t = new Point[n];
for (i = 0; i < n; i++)
cin >> t[i].x >> t[i].y;
for (i = 0; i < n; i++)
cout << "mas x" << t[i].x << " y =" << t[i].y << endl;
r = dist_matrix(t, n);
for (i = 0; i < n - 1; i++) {
cout << endl;
for (j = i + 1; j < n; j++)
cout << r[i][j] << " ";
}
cout<<" r 00 "<< r[0][1];
cin >> i;
return 0;
}
double rast(const Point &t1, const Point &t2) {
double r;
r = sqrt((t1.x - t2.x) * (t1.x - t2.x) + (t1.y - t2.y) * (t1.y - t2.y));
return r;
}
double **dist_matrix(Point *a, int n) {
double **p;
int i, j;
p = new double *[n];
for (i = 0; i < n; i++)
p[i] = new double[n];
for (i = 0; i < n - 1; i++)
for (j = i + 1; j < n; j++)
p[i][j] = rast(a[i], a[j]);
cout<<" ff r 00 "<< p[0][1];
return p;
}