Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <string>
  5. #include <math.h>
  6.  
  7. using namespace std;
  8. struct point {
  9. double x;
  10. double y;
  11. double z;
  12.  
  13. };
  14.  
  15. double distance(point a, point b) {
  16. return sqrt((a.x - b.x)*(a.x - b.x) +
  17. (a.y - b.y)*(a.y - b.y) + (a.z - b.z)*(a.z - b.z));
  18. }
  19.  
  20.  
  21. int main() {
  22. int r;
  23. point p[30];
  24. int count;
  25. cout << "Vvedite tochki < 30";
  26. cin >> count;
  27. for (int i = 0; i < count; ++i) {
  28. cin >> p[i].x >> p[i].y >> p[i].z;
  29. }
  30. cout << "Radius";
  31. cin >> r;
  32. int n = 0, max=0, imax,k=0;
  33. for (int i = 0; i < count; i++) {
  34. for (int j = 0; j<count; j++) {
  35.  
  36. if (j != i) {
  37. if (distance(p[i], p[j])<=r) {
  38. k++;
  39. }
  40. }
  41.  
  42. }
  43.  
  44. if (i == 0) {
  45. max = k;
  46. imax = i;
  47. }
  48. else if (max < k){
  49. max = k;
  50. imax = i;
  51. }
  52. k = 0;
  53. }
  54. if (max == 0) {
  55. cout << "to4ek net";
  56. }
  57. else {
  58. cout << "Centre: x = " << p[imax].x << ", y = " << p[imax].y << ", z = " << p[imax].z;
  59. cout << endl << "to4ki v oblasti = " << max;
  60. }
  61.  
  62. system("pause");
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement