0 bình luận về “nhập dãy và in ra số lớn thứ 4(pascal)”
program timSo; uses crt; var a:array[1..250] of integer; t: integer; i,j, n: byte; begin clrscr; write(‘n = ‘); readln(n); for i:=1 to n do begin write(‘a[‘, i, ‘] = ‘); readln(a[i]); end; for i:=1 to n-1 do for j:=i+1 to n do if a[j]>a[i] then begin t:=a[i]; a[i]:=a[j]; a[j]:=t; end; for i:=1 to n-1 do if a[i]=a[i+1] then for j:=i+1 to n do a[j]:=a[j+1]; write(‘so lon thu tu la: ‘, a[4]); readln; end.
program timSo;
uses crt;
var a:array[1..250] of integer;
t: integer;
i,j, n: byte;
begin
clrscr;
write(‘n = ‘); readln(n);
for i:=1 to n do
begin
write(‘a[‘, i, ‘] = ‘); readln(a[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do if a[j]>a[i] then
begin
t:=a[i]; a[i]:=a[j]; a[j]:=t;
end;
for i:=1 to n-1 do if a[i]=a[i+1] then
for j:=i+1 to n do a[j]:=a[j+1];
write(‘so lon thu tu la: ‘, a[4]);
readln;
end.