uses crt; var i,n,max,max1:longint; a:array[1..10000000]of longint; begin clrscr; write(‘Nhap so luong phan tu: ‘);readln(n); for i:=1 to n do begin write(‘Nhap phan tu thu ‘,i,’: ‘);read(a[i]); end; for i:=1 to n do if a[i]>max then max:=a[i]; for i:=1 to n do if (a[i]<>max)and(a[i]>max1) then max1:=a[i]; writeln(‘So lon nhat: ‘,max); writeln(‘So lon nhi: ‘,max1); readln end.
Pic.
uses crt;
var i,n,max,max1:longint; a:array[1..10000000]of longint;
begin
clrscr;
write(‘Nhap so luong phan tu: ‘);readln(n);
for i:=1 to n do
begin
write(‘Nhap phan tu thu ‘,i,’: ‘);read(a[i]);
end;
for i:=1 to n do
if a[i]>max then max:=a[i];
for i:=1 to n do
if (a[i]<>max)and(a[i]>max1) then max1:=a[i];
writeln(‘So lon nhat: ‘,max);
writeln(‘So lon nhi: ‘,max1);
readln
end.