Const n=10; type mas=array[1..3*n] of integer; procedure ins(var a:mas;k,nom:integer); var i:integer; begin for i:=3*n downto nom+3 do a[i]:=a[i-2]; a[nom+1]:=a[nom]; a[nom]:=k; a[nom+2]:=k; end; var b : mas; k,i,j : integer; begin Randomize; for i:=1 to n do begin b[i]:=random(51); write(b[i]:4); end; writeln; write('K=');readln(k); j:=1; for i:=1 to n do if (b[j] mod 10 = k mod 10) then begin ins(b,k,j); j:=j+3 end else j:=j+1; for i:=1 to 3*n do write(b[i]:4); writeln; end.
type mas=array[1..3*n] of integer;
procedure ins(var a:mas;k,nom:integer);
var i:integer;
begin
for i:=3*n downto nom+3 do a[i]:=a[i-2];
a[nom+1]:=a[nom]; a[nom]:=k; a[nom+2]:=k;
end;
var b : mas; k,i,j : integer;
begin
Randomize;
for i:=1 to n do begin
b[i]:=random(51);
write(b[i]:4);
end;
writeln;
write('K=');readln(k);
j:=1;
for i:=1 to n do
if (b[j] mod 10 = k mod 10) then
begin ins(b,k,j); j:=j+3 end
else j:=j+1;
for i:=1 to 3*n do write(b[i]:4);
writeln;
end.