Documente Academic
Documente Profesional
Documente Cultură
11
PROGRAME TURBO PASCAL
Introdu M=360
F(1)=2 E(1)=3
F(2)=3 E(2)=2
F(3)=5 E(3)=1
Continuati(da=1/nu=0):
Program ordonare;
uses CRT;
type
vector= array[1..50] of real;
vectory=array[1..50] of integer;
var
n,i,j,comu,nv,yaux: integer;
xaux: real;
x,z: vector;
y: vectory;
begin
repeat
write (‘Introduceti N=’);
read (n);
until n>1;
writeln (‘Introduceti sirul X’);
for i:=1 to n do
begin
write (‘x(‘,i,’)=’);
read (x[i]);
end;
for i:=1 to n do
begin
z[i]:=x[i];
y[i]:=i;
end;
nv:=n-1;
repeat
comu:=0;
for i:=1 to nv do
begin
j:=i+1;
if x[i] > x[j]
then
begin
xaux:=x[i];
yaux:=y[i];
x[i]:=x[j];
y[i]:=y[j];
x[j]:=xaux;
y[j]:=yaux;
comu:=1;
end;
end;
until comu=0;
writeln (‘Sirul initial’);
for i:=1 to n do
write (‘z(‘,i,’)=’,z[i]: 6: 2,’; ‘);
writeln(‘ ‘);
writeln (‘Sirul ordonat’);
for i:=1 to n do
write (‘x(‘,i,’/’,y[i],’)=’,x[i]: 6: 2,’; ‘)
end.
Introduceti N=6
Introduceti sirul X
x(1)=173.5
x(2)=-2.07
x(3)=-35.0
x(4)=-11.0
x(5)=0.0
x(6)=4.10
Sirul initial
z(1)=173.50; z(2)= -2.07; z(3)=-35.00; z(4)=-11.00; z(5)= 0.00; z(6)= 4.10;
Sirul ordonat
x(1/3)=-35.00; x(2/4)=-11.00; x(3/2)= -2.07; x(4/5)= 0.00; x(5/6)= 4.10; x(6/1)=173.50;