uses crt; var n,i,max,nhi:integer; a:array[0..100] of integer; BEGIN clrscr; {NHAP DAY SO} write(‘Nhap n:’); readln(n); for i:=1 to n do begin write(‘Nhap a[‘,i,’]’); readln(a[i]); end; {TIM PHAN TU LON NHAT} max:=a[1]; for i:=2 to n do if a[i]>max then max:=a[i]; {TIM PHAN TU LON NHI} for i:=1 to n do if a[i]<max then begin nhi:=a[i]; break end; for i:=1 to n do if (a[i]<max) and (a[i]>nhi) then nhi:=a[i]; write(‘So lon nhi trong day so la:’,nhi); readln END.
program maxnhi;
var A:array[1..10000] of integer;
n,i,j,tg:integer;
begin
clrscr;
write(‘Nhap so luong phan tu n: ‘); readln(n);
writeln(‘NHAP GIA TRI TUNG PHAN TU CUA MANG’);
for i:=1 to n do
begin
write(‘Phan tu thu ‘,i,’: ‘);
readln(A[i]);
end;
write(‘mang vua nhap la: ‘);
for i:=1 to n do
write(A[i],’ ‘);
writeln;
for i:=1 to n-1 do
for j:=i+1 to n do
if A[i]<A[i] then
begin
tg:=A[i];
A[i]:=A[j];
A[j]:=tg;
end;
i:=2;
while A[i]=A[1] do
i:=i+1;
write(‘Phan tu lon nhi cua day la: ‘,A[i]);
readln
end.
uses crt;
var n,i,max,nhi:integer;
a:array[0..100] of integer;
BEGIN
clrscr;
{NHAP DAY SO}
write(‘Nhap n:’); readln(n);
for i:=1 to n do
begin
write(‘Nhap a[‘,i,’]’);
readln(a[i]);
end;
{TIM PHAN TU LON NHAT}
max:=a[1];
for i:=2 to n do
if a[i]>max then max:=a[i];
{TIM PHAN TU LON NHI}
for i:=1 to n do
if a[i]<max then
begin
nhi:=a[i];
break
end;
for i:=1 to n do
if (a[i]<max) and (a[i]>nhi) then
nhi:=a[i];
write(‘So lon nhi trong day so la:’,nhi);
readln
END.