Вопрос задан 17.06.2023 в 09:34. Предмет Информатика. Спрашивает Плужников Витя.

ЗРОБІТЬ ХОЧА Б ОДНЕ!!!C++Builder Обчисліть добуток всіх цілих <>0 чисел з інтервалу

[-6;5].Ввести з клавіатури n будь-яких чисел. Знайти середнє арифметичне однозначних​
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Мустафина Катя.

#include <iostream>

using namespace std;

int main()

{

  int mult = 1;

  for(int i = -6; i <= 5; i++)

      if(i != 0)

          mult *= i;

  cout << mult;

 return 0;

}

////////////////////////

#include <iostream>

using namespace std;

int main()

{

  float num;

  int counter = 0;

  float sum = 0;

  while(cin >> num)

  {

      sum += num;

      counter++;

  }

  cout << sum / counter;

  return 0;

}

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

To calculate the product of all non-zero integers within the interval [-6;5] and find the arithmetic mean of single-digit numbers, you can follow these steps:

1. Initialize two variables: `product` and `count`. Set `product` to 1 and `count` to 0. 2. Prompt the user to enter `n` numbers from the keyboard. 3. For each number entered, check if it is within the interval [-6;5]. - If the number is within the interval and is non-zero, multiply it with the current value of `product`. - If the number is a single-digit number, add it to the current value of `count`. 4. After processing all the numbers, calculate the arithmetic mean of single-digit numbers by dividing the value of `count` by the total count of single-digit numbers. 5. Display the product of non-zero numbers and the arithmetic mean of single-digit numbers.

Here's an example implementation in C++:

```cpp #include

int main() { int product = 1; int count = 0; int n;

std::cout << "Enter the number of values: "; std::cin >> n;

for (int i = 0; i < n; i++) { int num; std::cout << "Enter a number: "; std::cin >> num;

if (num >= -6 && num <= 5) { if (num != 0) { product *= num; } if (num >= -9 && num <= 9) { count++; } } }

std::cout << "Product of non-zero numbers: " << product << std::endl; std::cout << "Arithmetic mean of single-digit numbers: " << static_cast(count) / n << std::endl;

return 0; } ```

Please note that this code assumes the user will enter `n` numbers, and it checks if each number is within the interval [-6;5] and if it is non-zero. It also counts the single-digit numbers and calculates their arithmetic mean. Finally, it displays the product of non-zero numbers and the arithmetic mean of single-digit numbers.

Let me know if you have any further questions!

0 0

Похожие вопросы

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос