bài tập pascal

M

modtinhoc

const Nmax=250;
type Arint=array[1..Nmax] of integer;
var N,i,j,t,tong,dem:integer;
A:arrint;
begin
write('nhap so luong phan tu'); readln(N);
for i:=1 to N do begin
write ('phan tu'); readln(A); end;
for j:=N downto 2 do
for i:=1 to j-1 do
if A>A[i+1] then
begin
t:=A;
A:=A[i+1];
A[i+1]:=t;
end;
tong:=0;
dem:=0;
for i:=1 to N do
begin
tong:=tong+A;
if A mod 2=0 then dem:=dem+1;
end;
writeln('day dc sap xap la'); for i:=1 to N do write(A:4);
writeln('tong',tong);
writeln('so chia het cho 2',dem);
readln
end.
 
Top Bottom