1.
program test;
var i,k2,k3,k4,k5:integer;
a:array [1..20] of integer;
begin
k2:=0;
k3:=0;
k4:=0;
k5:=0;
for i:=1 to 20 do
a[i]:=random(4)+2;
if a[i]=2 then k2:=k2+1;
if a[i]=3 then k3:=k3+1;
if a[i]=4 then k4:=k4+1;
if a[i]=5 then k5:=k5+1;
write(a[i],' ')
end;
writeln;
writeln(k2);
writeln(k3);
writeln(k4);
write(k5)
end.
2.
var i,j,v:integer;
a:array [1..10] of integer;
for i:=1 to 10 do
a[i]:=random (100);
write(a[i]:3)
for i:=1 to 9 do
for j:=1 to 9 do
if a[j]>a[j+1] then
v:=a[j];
a[j]:=a[j+1];
a[j+1]:=v
for i:=1 to 10 do write(a[i]:3)
3.
var a:array [1..10] of integer;
i,j,m,v:integer;
randomize;
a[i]:=random(100);
m:=i;
for j:=i to 10 do
if a[m] mod 10 < a[j] mod 10 then m:=j;
v := a[i];
a[i]:= a[m];
a[m] := v;
1.
program test;
var i,k2,k3,k4,k5:integer;
a:array [1..20] of integer;
begin
k2:=0;
k3:=0;
k4:=0;
k5:=0;
for i:=1 to 20 do
begin
a[i]:=random(4)+2;
if a[i]=2 then k2:=k2+1;
if a[i]=3 then k3:=k3+1;
if a[i]=4 then k4:=k4+1;
if a[i]=5 then k5:=k5+1;
write(a[i],' ')
end;
writeln;
writeln(k2);
writeln(k3);
writeln(k4);
write(k5)
end.
2.
var i,j,v:integer;
a:array [1..10] of integer;
begin
for i:=1 to 10 do
begin
a[i]:=random (100);
write(a[i]:3)
end;
for i:=1 to 9 do
for j:=1 to 9 do
if a[j]>a[j+1] then
begin
v:=a[j];
a[j]:=a[j+1];
a[j+1]:=v
end;
writeln;
for i:=1 to 10 do write(a[i]:3)
end.
3.
var a:array [1..10] of integer;
i,j,m,v:integer;
begin
randomize;
for i:=1 to 10 do
begin
a[i]:=random(100);
write(a[i]:3)
end;
writeln;
for i:=1 to 10 do
begin
m:=i;
for j:=i to 10 do
if a[m] mod 10 < a[j] mod 10 then m:=j;
v := a[i];
a[i]:= a[m];
a[m] := v;
write(a[i]:3)
end;
end.