Const n=10;
var a:array[1..n] of integer;
max,i:integer;
begin
Randomize;
for i:=1 to n do begin
a[i]:=random(51);
write(a[i],' ');
end;
writeln;
max:=a[1];
for i:=2 to n do
if a[i]>max then max:=a[i];
writeln('max = ',max);
for i:=1 to n do
if i mod 2=1 then a[i]:=max;
for i:=1 to n do write(a[i],' ');
writeln;
end.
Пример:
17 25 32 37 31 46 12 22 29 7
max = 46
46 25 46 37 46 46 46 22 46 7