Program PAS; Const N = 14; Var A:Array[1..N] of integer; i,Max,Min:integer; Begin Randomize; Write('Исходный массив:'); For i:= 1 to N do Begin A[i]:=random(90)+1; Write(' ',A[i]); End; WriteLn; Max:=1; Min:=1; For i:= 2 to N do Begin if A[i]>A[Max] then Max:=i; if A[i]<A[Min] then Min:=i; End; WriteLn('Max(A) = A[',Max,'] = ',A[Max]); WriteLn('Min(A) = A[',Min,'] = ',A[Min]) End.
Const
N = 14;
Var
A:Array[1..N] of integer;
i,Max,Min:integer;
Begin
Randomize;
Write('Исходный массив:');
For i:= 1 to N do
Begin
A[i]:=random(90)+1;
Write(' ',A[i]);
End;
WriteLn;
Max:=1;
Min:=1;
For i:= 2 to N do
Begin
if A[i]>A[Max] then Max:=i;
if A[i]<A[Min] then Min:=i;
End;
WriteLn('Max(A) = A[',Max,'] = ',A[Max]);
WriteLn('Min(A) = A[',Min,'] = ',A[Min])
End.
Пример:
Исходный массив: 66 70 88 36 30 11 53 1 57 77 6 40 65 46
Max(A) = A[3] = 88
Min(A) = A[8] = 1