var i,n,s:integer;
A:array[1..100] ò longint;
begin
readln(n);
for i:=1 to n do
begin
write('A[',i,']=');
readln(A[i]);
end;
s:=0;
for i:=1 to n do s:=s+A[i];
write(s);
s:=0;
if A[i] mod 2=0 then s:=s+A[i];
write(s);
end.
uses crt;
var n,i,tong,tongc,tongle:integer;
a:array[1..100] of integer;
begin
clrscr;
write('nhap n:');readln(n);
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
end;
writeln('mang vua nhap la:');
for i:=1 to n do write(a[i]:2);
tong:=0; tongc:=0; tongle:=0;
for i:=1 to n do
begin
tong:=tong+a[i];
if a[i] mod 2 = 0 then tongc:=tongc+a[i]
else tongle:=tongle+a[i];
end;
writeln('tong cac phan tu trong mangla:', tong);
writeln('tong cac phan tu chan la:', tongc);
writeln('tong cac phan tu le la:', tongle);
write('tong cac phan tu chia het cho 2 la:', tongc);
readln;
end.
* vì số chẵn là số chia hết cho 2 nên tổng các phần tử chia hết cho 2 cũng là tổng các số chẵn,
program bt;
var a:array[1..1000] of integer;
i,n,t:integer;
begin
write('nhap so phan tu cua mang');
readln(n);
for i:=1 to n do
begin
write('phan tu thu ',i,' : ');
readln(a[i]);
end;
for i:=1 to n do
t:= t + a[i] ;
write('tong cac phan tu trong mang la :',t);
readln
end.
d) Program Sara_Trang;
uses crt;
var i,n,tong:integer;
m:array [1..100] of real;
Begin
clrscr;
Write('Nhap so phan tu:'); Readln(n);
For i:=1 to n do
Begin
Write('M[',i,']='); Readln(M[i]);
End;
tong:=0;
For i:=1 to n do If M[i] mod 2=0 then tong:=M[i]+tong;
Writeln('Tong cua cac so chia het cho 2:');
Readln
End.
c) Program Sara_Trang;
uses crt;
var i,n,s1,s2:integer;
M:array [1..100] of integer;
Begin
clrsscr;
Write('Nhap so phan tu:'); Readln(n);
For i:=1 to n do
Begin
Write('M[',i,']='); Readln(M[i]);
End;
s1:=0; s2:=0;
For i:=1 to n do If M[i] mod 2=0 then s1:=M[i]+s1;
For i:=1 to n do If M[i] mod 2=1 then s2:=M[i]+s2;
Writeln('Tong cua cac so chan:',s1);
Writeln('Tong cua cac so le:',s2);
Readln
End.
var i,n,s:integer;
A:array[1..100] ò longint;
begin
readln(n);
for i:=1 to n do
begin
write('A[',i,']=');
readln(A[i]);
end;
s:=0;
for i:=1 to n do s:=s+A[i];
write(s);
s:=0;
if A[i] mod 2=0 then s:=s+A[i];
write(s);
end.