uses crt; var n,i,min1,min2:longint; a:array[1..1000000]of longint; begin clrscr; write(‘Nhap so phan tu: ‘);readln(n); min1:=high(longint); min2:=high(longint); for i:=1 to n do begin write(‘a[‘,i,’]=’);readln(a[i]); if a[i]<min1 then min1:=a[i]; end; for i:=1 to n do if(a[i]<min2)and(a[i]<>min1) then min2:=a[i]; writeln(min2); readln end.
program min_nhi;
uses crt;
var A:array[1..100] of integer;
n,i,j,tg:integer;
begin
clrscr;
write(‘Nhap so luong phan tu cua mang: ‘); readln(n);
for i:=1 to n do
begin
write(‘Nhap so thu ‘,i,’: ‘); readln(A[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if A[i]<A[j] 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(‘So nho nhi trong mang la: ‘,A[i]);
readln;
end.
#đúng 100%
uses crt;
var n,i,min1,min2:longint; a:array[1..1000000]of longint;
begin
clrscr;
write(‘Nhap so phan tu: ‘);readln(n);
min1:=high(longint); min2:=high(longint);
for i:=1 to n do
begin
write(‘a[‘,i,’]=’);readln(a[i]);
if a[i]<min1 then min1:=a[i];
end;
for i:=1 to n do if(a[i]<min2)and(a[i]<>min1) then min2:=a[i];
writeln(min2);
readln
end.