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

Пожалуйста!!! очень срочно...
Определить среднее арифметическое положительных элементов массива A, и вывести на экран номера нулевых элементов массива. A=(3,2;2,5;0;0,7;0;-1,3;4,3;-2,9;0;-0,4;-5,2;3,4) . Вывести на экран результаты и заданный массив. Pascal.

Ответы

Автор ответа: ingr
0

var

   a : array of real := (3.2,2.5,0,0.7,0,-1.3,4.3,-2.9,0,-0.4,-5.2,3.4);

   n : integer;

   s : real;

   

begin

   writeln('массив a = ', a);

   write('номера элементов равных 0: ');

   for var i :=0 to a.Length-1 do begin

       if a[i] = 0 then write(' ', i);

       if a[i] > 0 then begin

           n += 1;

           s += a[i];

       end;

   end;

   writeln;

   writeln('s = ', s/n);

end.


ingr: да, не забудь нумерация в массиве начинается с 0 а не с 1
Похожие вопросы
Предмет: Английский язык, автор: 1klayson5345
Виконайте тести.
1. What is "the environment"?
a) It is an ecological problem/
b) It is everything around us.
c) It is a green company.
d) It is the synonym to the word " nature"/
2. When do people all over the world celebrate the Earth Day?
a) April, 23.
b) April, 22.
c) The last Sunday in April.
d) May,23/
3. що означає Environmantly friendly?
a) дружній до довкілля;
ь) екологічно чистий;
с) друг природи;
d) без ГМО.
4. Що означає "global warming"?
a)зміна клімату.
ь) озоновий шар.
с) глобальне потепління.
d) знищення лісів.
5. Що означає слово "protect"?
а) руйнувати;
ь) захищати;
с) знищувати;
d) зберігати.
6. When was the accident at the Chornobyl nuclear power station?
a) in April, 1986
b) in April, 1996.
c) In April, 1886.
7. We pollute water with:
a) industrial waste.
b) chemical waste.
c) smoke and gases.
8. We pollute air with:
a) smoke and gases.
b) littering.
c) industrial waste.
9. The action of using something again:
a) reducing,
b) reusing,
c) recycling,
d) saving.
10. Що означає англійською "переробляти"?
a) to reuse,
b) to recycle,
c) to reduce.
11. Making rivers, air, etc. dirty:
a) pollution,
b) waist,
c) poison.
12. Thick forests in the tropical part of the world:
a) woods,
b) rainforests,
c) national parks.
13.Penicillin was... by A. Fleming.
a) discovered,
b) discovery,
c) invented,
d) invention.
14. The mobile phone is a wonderful ..... .
a) discover,
b) discovery,
c) invented,
d)invention.
15. If Peter .... to my place we .... in the yard.
a) comes, will play.
b) will come, plays.
c) came, will play.
16. I..... TV if my friends ..... to my place.
a) will watch, don't come.
b) will watch, comes.
c) watch, won't come.