Var ar:array[1..n] of integer; ar2:array[1..n] of integer; i,k:integer;
function prost(a:integer):boolean; var i:integer; b:boolean; begin b:=true; for i:=2 to a div 2 do if a mod i=0 then begin; b:=false; break; end; if a=1 then b:=false; prost:=b; end;
begin; randomize; k:=0; for i:=1 to n do begin; ar[i]:=random(101); write(ar[i]:4); end; writeln; for i:=1 to n do if prost(ar[i]) then begin; inc(k); ar2[k]:=ar[i]; write(ar2[k]:4); end; end.
begin
var x:=-2.0;
while x<=2 do begin
Writeln('x=',x:4:1,' y=',x*x*x+12:6:3);
x+=0.2
end
end.
Результат выполнения программы:
x=-2.0 y= 4.000
x=-1.8 y= 6.168
x=-1.6 y= 7.904
x=-1.4 y= 9.256
x=-1.2 y=10.272
x=-1.0 y=11.000
x=-0.8 y=11.488
x=-0.6 y=11.784
x=-0.4 y=11.936
x=-0.2 y=11.992
x= 0.0 y=12.000
x= 0.2 y=12.008
x= 0.4 y=12.064
x= 0.6 y=12.216
x= 0.8 y=12.512
x= 1.0 y=13.000
x= 1.2 y=13.728
x= 1.4 y=14.744
x= 1.6 y=16.096
x= 1.8 y=17.832
x= 2.0 y=20.000
n=5;
Var
ar:array[1..n] of integer;
ar2:array[1..n] of integer;
i,k:integer;
function prost(a:integer):boolean;
var i:integer;
b:boolean;
begin
b:=true;
for i:=2 to a div 2 do
if a mod i=0 then
begin;
b:=false;
break;
end;
if a=1 then b:=false;
prost:=b;
end;
begin;
randomize;
k:=0;
for i:=1 to n do
begin;
ar[i]:=random(101);
write(ar[i]:4);
end;
writeln;
for i:=1 to n do
if prost(ar[i]) then
begin;
inc(k);
ar2[k]:=ar[i];
write(ar2[k]:4);
end;
end.