Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <math.h>
- using namespace std;
- struct point {
- double x;
- double y;
- double z;
- };
- double distance(point a, point b) {
- return sqrt((a.x - b.x)*(a.x - b.x) +
- (a.y - b.y)*(a.y - b.y) + (a.z - b.z)*(a.z - b.z));
- }
- int main() {
- int r;
- point p[30];
- int count;
- cout << "Vvedite tochki < 30";
- cin >> count;
- for (int i = 0; i < count; ++i) {
- cin >> p[i].x >> p[i].y >> p[i].z;
- }
- cout << "Radius";
- cin >> r;
- int n = 0, max=0, imax,k=0;
- for (int i = 0; i < count; i++) {
- for (int j = 0; j<count; j++) {
- if (j != i) {
- if (distance(p[i], p[j])<=r) {
- k++;
- }
- }
- }
- if (i == 0) {
- max = k;
- imax = i;
- }
- else if (max < k){
- max = k;
- imax = i;
- }
- k = 0;
- }
- if (max == 0) {
- cout << "to4ek net";
- }
- else {
- cout << "Centre: x = " << p[imax].x << ", y = " << p[imax].y << ", z = " << p[imax].z;
- cout << endl << "to4ki v oblasti = " << max;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement