Запишите полный текст программы.
for i:= to n-1 do;
begin
imax:=i ;
for j:=i+1 to n do if a[ j]>a[imax] then imax:=j;
x:=a[i] ;
a[i];=a[imax];
a[imax]:=x ;
Ответы
Ответ дал:
0
const
n = 20;
var
i, imax, j, x: integer;
a: array[1..n]of integer;
begin
for i := 1 to n do
a[i] := random(100);
for i := 1 to n - 1 do
begin
imax := i;
for j := i + 1 to n do
if a[j] > a[imax] then
imax := j;
x := a[i];
a[i] := a[imax];
a[imax] := x;
end;
for i := 1 to n do
write(a[i],' ');
writeln();
writeln(imax);
end.
n = 20;
var
i, imax, j, x: integer;
a: array[1..n]of integer;
begin
for i := 1 to n do
a[i] := random(100);
for i := 1 to n - 1 do
begin
imax := i;
for j := i + 1 to n do
if a[j] > a[imax] then
imax := j;
x := a[i];
a[i] := a[imax];
a[imax] := x;
end;
for i := 1 to n do
write(a[i],' ');
writeln();
writeln(imax);
end.
Похожие вопросы
2 года назад
2 года назад
7 лет назад
10 лет назад
10 лет назад
10 лет назад