Вопрос задан 28.09.2018 в 14:47. Предмет Информатика. Спрашивает Паркаев Максим.

На­пи­ши­те про­грам­му, ко­то­рая в по­сле­до­ва­тель­но­сти на­ту­раль­ных чисел опре­де­ля­ет

ми­ни­маль­ное число, крат­ное 5. Про­грам­ма по­лу­ча­ет на вход ко­ли­че­ство чисел в по­сле­до­ва­тель­но­сти, а затем сами числа. В по­сле­до­ва­тель­но­сти все­гда име­ет­ся число, крат­ное 5. Ко­ли­че­ство чисел не пре­вы­ша­ет 1000. Введённые числа не пре­вы­ша­ют 30 000. Про­грам­ма долж­на вы­ве­сти одно число — ми­ни­маль­ное число, крат­ное 5.
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Kout Paul.
Program n1;
var k,i,min,a: integer;
begin
readln(k);
min:=30000;
for i:=1 to k do
begin
readln(a);
if (a mod 5=0) and (a<min) then min:=a;
end;
writeln(min);
end.
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Answer in detail. Write a program that determines the minimum number that is divisible by 5 in a sequence of natural numbers. The program receives the number of numbers in the sequence as input, and then the numbers themselves. There is always a number divisible by 5 in the sequence. The number of numbers does not exceed 1000. The entered numbers do not exceed 30,000. The program should output one number - the minimum number that is divisible by 5.

Here is a possible solution in Python:

```python # Read the number of numbers in the sequence n = int(input())

# Initialize the minimum number divisible by 5 as a large value min_div_5 = 30001

# Loop through the sequence for i in range(n): # Read the next number num = int(input()) # Check if it is divisible by 5 and smaller than the current minimum if num % 5 == 0 and num < min_div_5: # Update the minimum min_div_5 = num

# Print the minimum number divisible by 5 print(min_div_5) ```

This program uses a loop to iterate through the sequence of numbers and keeps track of the smallest number that is divisible by 5. It uses the modulo operator (%) to check if a number is divisible by 5. It prints the final result after the loop ends.

0 0

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

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

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