Cho N và dãy số a1 …. a_n.hãy tính tổng trong dãy có giá trị > hoặc =6
0 bình luận về “Cho N và dãy số a1 – a_n.hãy tính tổng trong dãy có giá trị > hoặc =6”
Program BTT; Uses crt; Var A: array[1..10000] of longint; n,i,s: longint; Begin Clrscr; Write(‘Nhap so luong phan tu: ‘); Readln(n); For i:=1 to n do Begin Write(‘A[‘,i,’] = ‘); Readln(A[i]); End;
s:=0; For i:=1 to n do If A[i]>=6 then s:=s+A[i]; Write(‘Tong la: ‘,s); Readln End.
Program BTT;
Uses crt;
Var A: array[1..10000] of longint;
n,i,s: longint;
Begin
Clrscr;
Write(‘Nhap so luong phan tu: ‘); Readln(n);
For i:=1 to n do
Begin
Write(‘A[‘,i,’] = ‘);
Readln(A[i]);
End;
s:=0;
For i:=1 to n do
If A[i]>=6 then s:=s+A[i];
Write(‘Tong la: ‘,s);
Readln
End.