Вопрос задан 31.07.2018 в 03:21. Предмет Информатика. Спрашивает Холод Людмила.

Помогите составить алгоритм на нахождение суммы неотрицательных чисел из 10 заданных!!!

0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Галушка Никита.
Неотрицательные-положительные.И кстати,где 10 заданых 
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Algorithm for Finding the Sum of Non-Negative Numbers

To find the sum of non-negative numbers from 10 given numbers, you can use the following algorithm:

1. Initialize a variable to store the sum. - Start with a variable initialized to 0 to store the sum of non-negative numbers.

2. Iterate through the given numbers. - Loop through each of the 10 given numbers.

3. Check if the number is non-negative. - For each number, check if it is non-negative (i.e., greater than or equal to 0).

4. Add non-negative numbers to the sum. - If the number is non-negative, add it to the sum.

5. Return the sum. - After iterating through all the given numbers, return the sum as the result.

Example Algorithm Implementation

Here's an example of how the algorithm can be implemented in Python:

```python # Initialize the sum sum_of_non_negative = 0

# Given numbers numbers = [2, 3, -8, -1, 2, 4, -2, 3, 5, 6]

# Iterate through the given numbers for num in numbers: # Check if the number is non-negative if num >= 0: # Add non-negative numbers to the sum sum_of_non_negative += num

# Return the sum print("The sum of non-negative numbers is:", sum_of_non_negative) ```

This algorithm will iterate through the given numbers, add the non-negative numbers to the sum, and return the final sum of non-negative numbers.

(#1)

0 0

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

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

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