uses crt;
var a: array [1..100] of integer;
n, i, tsc, tsl: integer
begin
clrscr;
write('So phan tu cua mang la: '); readln(n);
while n<1 do begin
write('So phan tu chi tu 2 tro len, ban da nhap sai, nhap lai: '); readln(n);
end;
for i:=1 to n do begin
write('So thu ',i,' la: '); readln(a[i]);
end;
tsc:=0;
tsl:=0;
for i:=1 to n do
if a[i] mod 2 =0 then tsc:=tsc+a[i]
else tsl:=tsl+a[i];
writeln('tong cac so chan la: ',tsc);
write('tong so cac so le la: ',tsl);
readln;
end.
Program bai1;
uses crt;
var i,n,s,s1: integer;
a:array[1..100] of integer;
begin
clrscr;
write('nhap n =');readln(n);
for i:=1 to n do
begin
write('nhap a[',i,'] ='); readln(a[i]);
end;
for i:= 1 to n do
if a[i] mod 2 = 0 then s:=s+a[i];
writeln('tong cac so duong = ' ,s);
for i:= 1 to n do
if a[i] mod 2 <> 0 then s1:=s1+a[i];
writeln('tong cac so le =' ,s1);
readln;
end.