tạo mảng a gom 100 phan tu viet chuong trinh tinh tong cac co co chi so le
2 câu trả lời
uses crt;
var A : array [1 .. 100] of integer;
i, n, S : integer;
begin
clrscr;
S := 0;
write('Nhap so phan tu = '); readln(n);
write('Nhap mang gom ', n ,' so : ');
for i := 1 to n do begin read(A[i]);
if i mod 2 <> 0 then S := S + A[i]; end;
write('Tong phan tu chi so le : ', S);
readln
end.
Program NN;
Uses crt;
Var A: array[1..100] of longint;
n,i,s: longint;
Begin
Clrscr;
Write('Nhap n: '); Readln(n);
s:=0;
For i:=1 to n do
Begin
Read(A[i]);
If i mod 2 <> 0 then s:=s+A[i];
End;
Write('S = ',s);
Readln
End.