Uses crt; const n=10; var a:array[1..n] of integer; i,max,k:integer; begin randomize; for i:=1 to n do begin a[i]:=random(30); writeln(a[i]); end; writeln; max:=0; for i:=1 to n do begin if a[i]>max then begin max:=a[i]; k:=i; end; end; a[k]:=a[k]+a[n]; a[n]:=a[k]-a[n]; a[k]:=a[k]-a[n]; for i:=1 to n do writeln(a[i]); end.
Program Max; Const first = 1; last = 10; Var a: Array [first..last] Of Integer; m, tmp, i: Integer; Begin WriteLn('Введите через пробел ', last, ' чисел'); For i := first To last Do Read(a[i]); m := first; For i := first To last Do If a[i] > a[m] Then m := i; tmp := a[last]; a[last] := a[m]; a[m] := tmp; WriteLn('Результат:'); For i := first To Last Do Write(a[i], ' '); ReadLn; End.
const n=10;
var a:array[1..n] of integer;
i,max,k:integer;
begin
randomize;
for i:=1 to n do
begin
a[i]:=random(30);
writeln(a[i]);
end;
writeln;
max:=0;
for i:=1 to n do
begin
if a[i]>max then begin
max:=a[i];
k:=i;
end;
end;
a[k]:=a[k]+a[n];
a[n]:=a[k]-a[n];
a[k]:=a[k]-a[n];
for i:=1 to n do
writeln(a[i]);
end.
Const first = 1; last = 10;
Var a: Array [first..last] Of Integer;
m, tmp, i: Integer;
Begin
WriteLn('Введите через пробел ', last, ' чисел');
For i := first To last Do
Read(a[i]);
m := first;
For i := first To last Do
If a[i] > a[m] Then
m := i;
tmp := a[last];
a[last] := a[m];
a[m] := tmp;
WriteLn('Результат:');
For i := first To Last Do
Write(a[i], ' ');
ReadLn;
End.