giup minh viet chuong trinh?

M

megamanxza

Mã:
[B][COLOR="Blue"]Uses crt;
var a: array [1..100] of integer;
      i, n, tongam, tongduong: integer;
begin
clrscr;
write ('Nhap so phan tu cua mang: '); readln (n);
for i:= 1 to n do
  begin
    write ('Nhap phan tu thu ',i,' cua mang: '); readln (a[i]);
    if a[i]<0 then tongam:=tongam+a[i];
    if a[i]>0 then tongduong:=tongduong+a[i];
  end;
write ('Cac phan tu duong trong mang: ');
for i:= 1 to n do
  if a[i]>0 then write (a[i],' ');
writeln; write ('Cac phan tu am trong mang: ');
for i:= 1 to n do
  if a[i]<0 then write (a[i],' ');
writeln ('Tong cac phan tu duong trong mang la ',tongduong);
write ('Tong cac phan tu am trong mang la ',tongam);
readln
end.[/COLOR][/B]
 
Top Bottom