Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. TPoints = array[1..2, 1..10] of real;
  2.  
  3. var
  4. pos : TPoints = (
  5. (145, 33, 33, 122, 78, 126, 125, 114, 126, 138),
  6. (112, 168, 162, 58, 98, 82, 93, -58, -28, -62));
  7. // (1,2,3,4,5,6,7,8,9,10),
  8. // (1,1,1,1,20,1,1,1,1,1));
  9. left, right : real;
  10. dx : real = 0.001;
  11. ox : real;
  12. min : real;
  13. temp : real;
  14.  
  15.  
  16. function dist(x1 : real; y1 : real; x2 : real; y2 : real) : real;
  17. begin
  18. result := sqrt(sqr(x2 - x1) + sqr(y2 - y1));
  19. end;
  20.  
  21. function d_max(x : real; point : TPoints) : real;
  22. var
  23. max : real;
  24. i : integer;
  25. begin
  26. max := dist(x, 0, point[1,1], point[2,1]);
  27. for i := 2 to 10 do
  28. if dist(x, 0, point[1,i], point[2,i]) > max then
  29. max := dist(x, 0, point[1,i], point[2,i]);
  30. result := max;
  31. end;
  32.  
  33. procedure bounds(arr : array of real; var max, min : real);
  34. var
  35. i : integer;
  36. begin
  37. max := arr[0];
  38. min := arr[0];
  39. for i := 1 to 9 do
  40. begin
  41. if arr[i] > max then
  42. max := arr[i];
  43. if arr[i] < min then
  44. min := arr[i];
  45. end;
  46. end;
  47.  
  48. {основная часть}
  49. begin
  50. {поиск границ исследуемой области}
  51. bounds(pos[1], right, left);
  52. writeln(left:0:3,'..',right:0:3);
  53. {перебор абсцисс}
  54. ox := left;
  55. min := d_max(left, pos);
  56. while left < right do
  57. begin
  58. left := left + dx;
  59. temp := d_max(left, pos);
  60. if temp < min then
  61. begin
  62. ox := left;
  63. min := temp;
  64. end;
  65. end;
  66. {вывод результата}
  67. writeln('X = ',ox:0:3,#10#13,'max_dist = ',min:0:3);
  68. readln;
  69. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement