Uses Crt;
Const
N = 100;
Var
A:array[1..N] of real;
i,k:integer;
S:real;
Begin
ClrScr;
k:=0;
Write('Исходный массив:');
For i:= 1 to N do
Begin
A[i]:=Sin(i)*Cos(i);
Write(' ',A[i]:0:3);
if A[i] <> 0 then
Begin
k:=k+1;
S:=S+A[i]
End;
End;
WriteLn;
WriteLn('Sr = ',S/k);
ReadLn
End.
Результат работы программы:
Исходный массив: Исходный массив: 0.455 -0.378 -0.140 0.495 -0.272 -0.268 0.495 -0.144 -0.375 0.456 -0.004 -0.453 0.381 0.135 -0.494 0.276 0.265 -0.496 0.148 0.373 -0.458 0.009 0.451 -0.384 -0.131 0.493 -0.279 -0.261 0.496 -0.152 -0.370 0.460 -0.013 -0.449 0.387 0.127 -0.493 0.283 0.257 -0.497 0.157 0.367 -0.462 0.018 0.447 -0.390 -0.123 0.492 -0.287 -0.253 0.497 -0.161 -0.364 0.463 -0.022 -0.445 0.392 0.118 -0.491 0.290 0.249 -0.498 0.165 0.361 -0.465 0.027 0.443 -0.395 -0.114 0.490 -0.294 -0.246 0.498 -0.169 -0.357 0.467 -0.031 -0.441 0.398 0.110 -0.489 0.297 0.242 -0.499 0.173 0.354 -0.468 0.035 0.439 -0.401 -0.105 0.488 -0.301 -0.238 0.499 -0.177 -0.351 0.470 -0.040 -0.437
Sr = -0.00136006072493969