uses GraphABC;
var i,x:integer;
begin
SetWindowWidth(870);
SetWindowHeight(325);
SetFontSize(15);
TextOut(350,5,'Продолжительность жизни животных');
TextOut(15,200,'Белка 6');
TextOut(15,150,'Заяц 8');
TextOut(15,175,'Жираф 12');
TextOut(15,225,'Бегемот 40');
TextOut(15,100,'Медведь 45');
TextOut(15,75,'Слон 70');
TextOut(15,125,'Крокодил 80');
TextOut(15,50,'Черепаха 130');
SetFontSize(10);
TextOut(200,270,' 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130');
SetBrushColor(clblack);
SetPenWidth(2);
Rectangle (200,220,230,200);
Rectangle (200,170,240,150);
Rectangle (200,195,260,175);
Rectangle (200,245,400,225);
Rectangle (200,120,425,100);
Rectangle (200,95,550,75);
Rectangle (200,145,600,125);
Rectangle (200,70,850,50);
Line (200,0,200,325);
Line (0,260,870,260);
x:=225;
for i:=1 to 27 do
Line (x,255,x,265);
x:=x+25
end
end.
Объяснение:
картинка
// PascalABC.NET 3.1, сборка 1174 от 22.02.2016
begin
Writeln(Range(1,100).Select(i->sin(i)*cos(i)).Where(x->x<>0).Average)
end.
Тестовое решение:
-0.00136006072493969
2. А вот так учат писать это же школьные учителя:
// PascalABC.NET 3.1, сборка 1174 от 22.02.2016
var
m:array[1..100] of real;
i,k:integer;
s:real;
begin
s:=0;
k:=0;
for i:=1 to 100 do begin
m[i]:=sin(i)*cos(i);
if m[i]<>0 then begin
s:=s+m[i];
k:=k+1
end
end;
Writeln(s/k)
end.
Тестовое решение:
-0.00136006072493969
uses GraphABC;
var i,x:integer;
begin
SetWindowWidth(870);
SetWindowHeight(325);
SetFontSize(15);
TextOut(350,5,'Продолжительность жизни животных');
TextOut(15,200,'Белка 6');
TextOut(15,150,'Заяц 8');
TextOut(15,175,'Жираф 12');
TextOut(15,225,'Бегемот 40');
TextOut(15,100,'Медведь 45');
TextOut(15,75,'Слон 70');
TextOut(15,125,'Крокодил 80');
TextOut(15,50,'Черепаха 130');
SetFontSize(10);
TextOut(200,270,' 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130');
SetBrushColor(clblack);
SetPenWidth(2);
Rectangle (200,220,230,200);
Rectangle (200,170,240,150);
Rectangle (200,195,260,175);
Rectangle (200,245,400,225);
Rectangle (200,120,425,100);
Rectangle (200,95,550,75);
Rectangle (200,145,600,125);
Rectangle (200,70,850,50);
Line (200,0,200,325);
Line (0,260,870,260);
x:=225;
for i:=1 to 27 do
begin
Line (x,255,x,265);
x:=x+25
end
end.
Объяснение:
картинка