1)
var
i, max, maxin: smallint;
arr1, arr, sum: array[1..25] of smallint;
begin
max := -(MaxSmallInt);
randomize();
for i := 1 to 25 do
begin
arr[i] := Random(-100, 100);
arr1[i]:=arr[i];
write(arr[i], ' ');
while arr[i] <> 0 do
begin
sum[i] := abs(arr[i] mod 10) + sum[i];
arr[i] := arr[i] div 10;
if sum[i] > max then begin
max := sum[i];
maxin:=i;
end;
end;
end;
writeln();
writeln(arr1[maxin]);
end.
2)
var
i, sum: byte;
arr: array[1..20] of byte;
begin
sum := 0;
randomize();
for i := 1 to 20 do
begin
arr[i] := random(10);
write(arr[i], ' ');
if arr[i] = i then sum := i + sum;
end;
writeln();
writeln(sum);
end.