Var A:array[1..10000] of integer; i,n:integer; S:real; Begin Write('n = ');ReadLn(n); Write('Введите a1..a',n,': '); S:=0; For i:= 1 to N do Begin Read(A[i]); if (A[i] mod 4 = 0) then S:=S+A[i]; End; WriteLn('S = ',S); End.
Заполнение случайными числами:
Var A:array[1..10000] of integer; i,n:integer; S:real; Begin Randomize; Write('n = '); ReadLn(n); Write('a1..a',n,': '); S:=0; For i:= 1 to N do Begin A[i]:=random(2*N+1)-N; Write(A[i],' '); if (A[i] mod 4 = 0) then S:=S+A[i]; End; WriteLn; WriteLn('S = ',S); End.
Var
A:array[1..10000] of integer;
i,n:integer;
S:real;
Begin
Write('n = ');ReadLn(n);
Write('Введите a1..a',n,': ');
S:=0;
For i:= 1 to N do
Begin
Read(A[i]);
if (A[i] mod 4 = 0) then S:=S+A[i];
End;
WriteLn('S = ',S);
End.
Заполнение случайными числами:
Var
A:array[1..10000] of integer;
i,n:integer;
S:real;
Begin
Randomize;
Write('n = ');
ReadLn(n);
Write('a1..a',n,': ');
S:=0;
For i:= 1 to N do
Begin
A[i]:=random(2*N+1)-N;
Write(A[i],' ');
if (A[i] mod 4 = 0) then S:=S+A[i];
End;
WriteLn;
WriteLn('S = ',S);
End.