Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TPoints = array[1..2, 1..10] of real;
- var
- pos : TPoints = (
- (145, 33, 33, 122, 78, 126, 125, 114, 126, 138),
- (112, 168, 162, 58, 98, 82, 93, -58, -28, -62));
- // (1,2,3,4,5,6,7,8,9,10),
- // (1,1,1,1,20,1,1,1,1,1));
- left, right : real;
- dx : real = 0.001;
- ox : real;
- min : real;
- temp : real;
- function dist(x1 : real; y1 : real; x2 : real; y2 : real) : real;
- begin
- result := sqrt(sqr(x2 - x1) + sqr(y2 - y1));
- end;
- function d_max(x : real; point : TPoints) : real;
- var
- max : real;
- i : integer;
- begin
- max := dist(x, 0, point[1,1], point[2,1]);
- for i := 2 to 10 do
- if dist(x, 0, point[1,i], point[2,i]) > max then
- max := dist(x, 0, point[1,i], point[2,i]);
- result := max;
- end;
- procedure bounds(arr : array of real; var max, min : real);
- var
- i : integer;
- begin
- max := arr[0];
- min := arr[0];
- for i := 1 to 9 do
- begin
- if arr[i] > max then
- max := arr[i];
- if arr[i] < min then
- min := arr[i];
- end;
- end;
- {основная часть}
- begin
- {поиск границ исследуемой области}
- bounds(pos[1], right, left);
- writeln(left:0:3,'..',right:0:3);
- {перебор абсцисс}
- ox := left;
- min := d_max(left, pos);
- while left < right do
- begin
- left := left + dx;
- temp := d_max(left, pos);
- if temp < min then
- begin
- ox := left;
- min := temp;
- end;
- end;
- {вывод результата}
- writeln('X = ',ox:0:3,#10#13,'max_dist = ',min:0:3);
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement