Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- struct point
- {
- int x, y, z;
- };
- double dlina(point a, point b)
- {
- return sqrt ( pow (a.x - b.x, 2) + pow(a.y - b.y, 2) + pow(a.z - b.z, 2) );
- }
- int main()
- {
- int n;
- cout << "Введите кол-во точек в множестве: \n";
- cin >> n;
- point circle;
- point *m = new point [n];
- cout << "Введите элементы множества: \n";
- for (int i = 0; i < n; ++i)
- {
- cout << "Элемент № " << i << " :\n";
- cin >> m[i].x >> m[i].y >> m[i].z;
- }
- double r;
- cout << "Введите радиус шара: ";
- cin >> r;
- circle.x = 0; circle.y = 0; circle.z = 0;
- int min = n + 1;
- for (int i = 0; i < n; ++i)
- {
- int k = 0;
- for (int j = 0; j < n; ++j)
- if (dlina(m[i], m[j]) <= r) ++k;
- if (k < min) { min = k; circle = m[i]; }
- }
- cout << "Точка: " << "( " << circle.x << ", " << circle.y << ", " << circle.z << " )";
- delete[] m;
- return 0;
- }
Add Comment
Please, Sign In to add comment