Предмет: Информатика, автор: Santa2015

вычислить среднее геометрическое положительных элементов массива (a1,a2,...,a40), имеющих четные индексы. если таковых элементов нет, вывести на печать признак 0.
Выполнить нужно через массив в среде разработки Паскаль ABCNET

Ответы

Автор ответа: petyaGavrikov
0
// PascalABC.NET 3.3

begin
  var n:=40;
  var a:=ArrRandomInteger(n,-40,40); a.Println;
  var b:=a.Where((x,i)->(x>0)and(i mod 2=0));
  if b.Count=0 then writeln(0)
  else writeln(power(b.Aggregate(1,(p,q)->p*q),1/b.Count));
end.

Пример (для n=10):
-19 38 -37 18 9 -5 17 29 19 -2
14.2718961622815
Похожие вопросы
Предмет: Математика, автор: ahmerovaerika129
Предмет: Английский язык, автор: hororgameotcat
Use the words in capitals to form a new word that fits into each blank!

1. He gave us a detailed ____________________ of how the accident happened. (DESCRIBE)
2. He moved to the United ____________________a few years ago. (KING)
3. She has been doing research work as a ____________________. (SCIENCE)
4. I wanted to ____________________but Dad cut me off at once. (APOLOGY)
5. Most bird species are under ____________________by law. (PROTECT)
6. We enjoyed the ____________________of the ski hut at night. (WARM)
7. He is the most famous ____________________who has ever had an exhibition in this gallery. (ART)
8. After his mother's ____________________he moved to South America. (DIE)
9. I didn't tell him the whole ____________________. (TRUE)
10. Who was the last Roman ____________________? (EMPIRE)
11.Can you tell me the ____________________of the new restaurant? (LOCATE)
12.The hotel offers a great ____________________of activities tourists can do. (SELECT)
13.The view from the top of the mountain is absolutely ____________________. (FASCINATE)
14. ____________________, we didn't get caught cheating. (LUCK)
15.He likes reading ____________________. (POEM)
16.Even the FBI could not solve the ____________________crime. (MYSTERY)
17.She runs a ____________________business in Los Angeles. (SUCCEED)
18.They are doing some research on the ____________________of nuclear weapons. (DESTROY)
19. ____________________is a characteristic that many politicians lack. (HONEST)
20.Mum didn't go up to the top because she is afraid of ____________________. (HIGH)
21.It has snowed ____________________in the last 24 hours. (CONSIDER)
22.We were ____________________that our mother would survive surgery and get better soon. (HOPE)
23.There were a lot of ____________________parts that she did not understand. (MEANING)
24.After a few days, the family reported the ____________________to the police. (APPEAR)
25.We still didn't know the ____________________of the refugees. (NATION)
Предмет: Алгебра, автор: dgigit