В данной программе надо чтобы при запуске выводился на экран начальный массив из вещественных чисел(отрицательных и положительных) и после от туда выбирались элементы наиболее близкие какому нибудь целому числу .
Помогите плиз

const
n=10;
var
x: array [1..n] of real;
i,k : integer;
min,res : real;
begin
for i:=1 to n do
begin
write('x[',i,']=');
readln (x[i]);
end;
min:=1;
for i:=1 to n do
begin
if frac(x[i]) >=0.5 then res:=1-frac(x[i])
else res:=1-(1-frac(x[i]));
if res< min then
begin
min:=res;
k:=i;
end;
end;
write('Rezultat: ',x[k]:0:3);
readln;
end.
Uses crt;
const
n=10;
var
x: array [1..n] of real;
i,k : integer;
min,res : real;
begin
clrscr;
randomize;
for i:=1 to n do
begin
x[i]:=random(999);
end;
min:=1;
for i:=1 to n do
begin
if frac(x[i]) >=0.5 then res:=frac(x[i])
else res:=1-(1-frac(x[i]));
if res> min then
begin
min:=res;
k:=i;
end;
end;
for i:=1 to n do
begin
write (x[i]:0:1 ,' ');
end;
write('Rezultat: ',x[k]:0:3);
readln;
end.
2 695 562 910 134 940 115 370 251 261 Rezultat: 2.000
Uses crt;
const
n=10;
var
x: array [1..n] of real;
i,k : integer;
min,res : real;
begin
clrscr;
randomize;
writeln ('Ishodnii massiv');
for i:=1 to n do
begin
x[i]:=random(99)+random ;
if random > 0.5 then x[i]:=-x[i];
end;
min:=1;
for i:=1 to n do
begin
if frac(x[i]) >=0.5 then res:=1-frac(x[i])
else res:=1-(1- frac(x[i]));
if res< min then
begin
min:=res;
k:=i;
end;
end;
for i:=1 to n do
begin
write (x[i]:0:2 ,' ');
end;
writeln;
writeln ('Rezultat: ',x[k]:0:3);
readln;
end.
Ishodnii massiv
90.00 -23.67 66.71 98.17 -89.16 -12.07 48.47 -36.63 55.47 -14.76
Rezultat: -14.762