Вопрос задан 19.01.2020 в 11:37. Предмет Другие предметы. Спрашивает Калашникова Карина.

Информатика:Даны два целых числа, каждое записано в отдельной строке. Программа должна вывести

число 1, если первое число больше второго, число 2, если второе больше первого, или число 0, если они равны.
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Голдобина Екатерина.
Begin
if a> b then write ('1') else write ('2');
if a=b then write ('0');
end.
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Problem Statement

You are given two integers, each written on a separate line. Your program should output the number 1 if the first number is greater than the second number, the number 2 if the second number is greater than the first number, or the number 0 if they are equal.

Solution

To solve this problem, you can follow these steps:

1. Read the first integer from the input. 2. Read the second integer from the input. 3. Compare the two integers using an if-else statement. 4. If the first integer is greater than the second integer, output the number 1. 5. If the second integer is greater than the first integer, output the number 2. 6. If the two integers are equal, output the number 0.

Here's an example implementation in Python:

```python # Read the first integer num1 = int(input())

# Read the second integer num2 = int(input())

# Compare the two integers if num1 > num2: print(1) elif num2 > num1: print(2) else: print(0) ```

This program reads two integers from the input and compares them using an if-else statement. The appropriate number is then printed based on the comparison.

Let's consider an example: - Input: ``` 5 10 ``` - Output: ``` 2 ``` In this example, the second number (10) is greater than the first number (5), so the program outputs 2.

I hope this helps! Let me know if you have any further questions.

0 0

Топ вопросов за вчера в категории Другие предметы

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

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