Var a: array[1..n] of integer; k, i, m: byte; min: integer;
begin Write('Razmer massiva: '); Readln(k); if (k < 0) or (k > 100) then begin Writeln('Razmer dolzhen byt bolshe 0 i menshe 100'); Readln; Exit; end; Randomize; Writeln('Ishodn. massiv: '); for i:=1 to k do begin a[i]:=Random(101)-50; write(a[i]:4); end; min:=a[1]; for i:=2 to k do if a[i] < min then begin min:=a[i]; m:=i; end; a[m] := a[1]; a[1] := min; Writeln; Writeln('Min element = ', min:4, ' v posicii ', m:3); Writeln('Rezult. massiv: '); for i:=1 to k do write(a[i]:4); readln; end.
a: array[1..n] of integer;
k, i, m: byte;
min: integer;
begin
Write('Razmer massiva: ');
Readln(k);
if (k < 0) or (k > 100) then
begin
Writeln('Razmer dolzhen byt bolshe 0 i menshe 100');
Readln;
Exit;
end;
Randomize;
Writeln('Ishodn. massiv: ');
for i:=1 to k do
begin
a[i]:=Random(101)-50;
write(a[i]:4);
end;
min:=a[1];
for i:=2 to k do
if a[i] < min then
begin
min:=a[i];
m:=i;
end;
a[m] := a[1];
a[1] := min;
Writeln;
Writeln('Min element = ', min:4, ' v posicii ', m:3);
Writeln('Rezult. massiv: ');
for i:=1 to k do
write(a[i]:4);
readln;
end.