Помогите найти ошибку (Информатика, Паскаль).
var s,k,a:integer;
Begin
s:=0;
k:=0;
Read(a);
while a<>0 do
Begin
if a mod 8=0 then
Begin
s:=s+a;
k:=k+1;
end;
Readln(a);
end;
var y:real;
begin
y:= s/k;
Read(s);
if s>0 then
Writeln(y)
else
Writeln('NO')
end;
end.
Answers & Comments
Verified answer
Var s,k,a:integer;Begin
s:=0;
k:=0;
Readln(a);
while a<>0 do
Begin
if a mod 8=0 then
Begin
s:=s+a;
k:=k+1;
end;
Readln(a);
end;
if k>0 then Writeln(s/k)
else Writeln('NO')
end.
Пример:
43
61
16
95
24
0
20