Viết chương trình nhập vào 1 dãy số thực gồm 100 số hạng. Xuất ra màn dãy số đó được viết theo chiều ngược lại; tổng các số âm và số lượng số ko âm.

2 câu trả lời

Program BTT;
Uses crt;
Var A: array[1..100] of extended;
    i,d: longint;
    s: extended;
Begin
        Clrscr;
        s:=0; d:=0;
        For i:=1 to 100 do
        Begin
                Write('A[',i,'] = ');
                Readln(A[i]);
                If A[i]>0 then inc(d);
                If A[i]<0 then s:=s+A[i];
        End;
        For i:=100 downto 1 do
                Write(A[i]:0:2,' ');
        Writeln;
        Writeln('Tong cac so am: ',s:0:2);
        Write('So luong so khong am: ',d);
        Readln
End.


Var A: array[1..100] of extended;
    i,d: longint;
    s: extended;
Begin
    Clrscr;
       s:=0; d:=0;
        For i:=1 to 100 do
        Begin
        Write('A[',i,'] = ');
        Readln(A[i]);
         If A[i]>0 then inc(d);
          If A[i]<0 then s:=s+A[i];
        End;
        For i:=100 downto 1 do
          Write(A[i]:0:2,' ');
        Writeln;
        Writeln('Tong cac so am: ',s:0:2);
        Write('So luong so khong am: ',d);
        Readln
End.

Câu hỏi trong lớp Xem thêm