program tinhtong; Uses crt; Var A: array[1..1000] of integer; N, i, dem, tong: integer; Begin dem := 0; tong := 0; clrscr; Read(N); for i:=1 to N do Read(A[i]); for i:=1 to N do begin if (A[i] < 0) then dem := dem + 1; tong := tong + A[i]; end; writeln(tong); writeln(dem); End.
program mangnguyenA;
uses crt;
var A:array[1..10000] of integer;
n,i,d:integer;
tong:byte;
begin
clrscr;
write(‘Nhap so luong phan tu n: ‘); readln(n);
writeln(‘NHAP GIA TRI TUNG PHAN TU CUA MANG’);
tong:=0; d:=0;
for i:=1 to n do
begin
write(‘A[‘,i,’]= ‘);
readln(A[i]);
tong:=tong+A[i];
if A[i]<0 then d:=d+1;
end;
write(‘Mang nguyen A vua nhap la: ‘);
for i:=1 to n do
write(A[i],’ ‘);
writeln;
writeln(‘Tong cac phan tu cua mang la: ‘,tong);
writeln(‘Co ‘,d,’ phan tu am trong mang nguyen A’);
readln
end.
program tinhtong;
Uses crt;
Var
A: array[1..1000] of integer;
N, i, dem, tong: integer;
Begin
dem := 0;
tong := 0;
clrscr;
Read(N);
for i:=1 to N do Read(A[i]);
for i:=1 to N do
begin
if (A[i] < 0) then dem := dem + 1;
tong := tong + A[i];
end;
writeln(tong);
writeln(dem);
End.