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

Найти среднее арифметическое нечетных чисел в массиве а[10]
(Язык C++)

Ответы

Автор ответа: CptBrawis
3

#include <iostream>

#include <iomanip>

using namespace std;

int main() {

int k = 0;

double S = 0;

int a[10];

for (int i = 0; i < 10; i++)

{

 cin >> a[i];

 if (a[i] % 2 != 0 && a[i] != 0)

 {

  k++; S += a[i];

 }

}

S = S / k;

cout << setprecision(2) << fixed;

cout << "AVERAGE=" << S;

return 0;

}

Выводит с 2мя после запятой. Если надо поменять то сделайте в setprecision(нужноечислознаковпослезапятой).

Похожие вопросы
Предмет: Қазақ тiлi, автор: kuzmenkoaleksandra33
Предмет: Английский язык, автор: Аноним
Интернет урок помогите пожалуйстааааааа Английский....
Task 3 (40 points).

Read these sentences and choose the correct answer to fill in the gaps.



1. They haven't eaten for hours – they __________ be starving.

must
can
2. They're two hours late – there __________ be something wrong.

must
can
3. My sister is 5 years old but she __________ read.

must
can
4. It was really late. I __________ go home.

had to
must
5. You __________ press the button to open this door.

had to
must
6. She earns decent money. She __________ buy everything.

can
is able to
7. Will he __________ continue his journey?

can
be able to
8. I'm locked in! I __________ get out!

am not able to
can't
9. I __________ speak Spanish, but maybe I'll learn it someday.

couldn't
can't
10. In 1800, nobody __________ travel into space.

could
couldn't
11. If you worked harder, you __________ pass your exams.

can
could
12. Mary __________ play the piano wonderfully. She loves music.

can
has to
13. My eyes are not good. I __________ wear glasses.

am able to
have to
14. They __________ ride their bikes well now.

could
can
15. The bus doesn’t go to the city centre. You __________ change at the next stop.

has to
have to
16. I __________ walk in this park today.

must
can
17. We __________ jog tomorrow. It won’t rain.

will be able to
won’t be able to
18. My friends __________ get up early.

don't have to
doesn't have to
19. Mary __________ meet him today.

don’t have to
doesn’t have to
20. Mum __________ make sandwiches.

can
have to