Вопрос задан 11.12.2023 в 19:26. Предмет Информатика. Спрашивает Сивкович Богданка.

Даны три целых числа, записанных в отдельных строках. Определите, сколько среди них совпадающих.

Программа должна вывести одно из чисел: 3 (если все совпадают), 2 (если два совпадают) или 0 (если все числа различны). Sample Input 1: 6 6 6 Sample Output 1: 3 Sample Input 2: 7 8 7 Sample Output 2: 2 python даю 25 балов срочно
0 0
Перейти к ответам

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

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

Task Analysis

The task requires writing a program to determine the number of matching integers among three given integers.

Python Solution

Here's a Python program to solve the given task:

```python # Read three integers from input num1 = int(input()) num2 = int(input()) num3 = int(input())

# Check for matching integers if num1 == num2 == num3: print(3) # All three numbers are the same elif num1 == num2 or num2 == num3 or num1 == num3: print(2) # Two numbers are the same else: print(0) # All numbers are different ```

Explanation

- We read three integers from the input using the `input()` function and convert them to integers using the `int()` function. - We then check for matching integers using conditional statements: - If all three numbers are the same, we print 3. - If two numbers are the same, we print 2. - If all numbers are different, we print 0.

This program covers all possible cases and provides the required output based on the input.

Feel free to try this program with different inputs!

0 0

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

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

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

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