
Вопрос задан 27.07.2023 в 00:06.
Предмет Информатика.
Спрашивает Сухин Влад.
Var x,y,z:integer Begin; Read (x); Read (y); If x>y then write (x,'-',y,'=',z) Else write
(y,'-',x,'=',z) End. Я записываю числа 30 20 компьютер решает как 30-20=0 Подскажите как сделать так чтоб z находило а не писало 0.

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

Отвечает Аксёнова Анастасия.
If x>y then write (x,'-',y,'=',x-y)
Else write (y,'-',x,'=',y-x)
Else write (y,'-',x,'=',y-x)



Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.
To calculate the value of z
instead of just displaying it as 0, you need to perform the subtraction operation and assign the result to the variable z
. In the provided pseudo-code, the variable z
is not being assigned any value after the subtraction. Here's the corrected version of the code:
pascalVar x, y, z: integer Begin Read(x); Read(y); If x > y then z := x - y Else z := y - x; Write('z = ', z); End.
In this corrected version, the code first reads the values of x
and y
. Then, it checks whether x
is greater than y
. If it is, it subtracts y
from x
and stores the result in z
. If x
is not greater than y
, it subtracts x
from y
and stores the result in z
. Finally, the code displays the value of z
.
With this change, if you input 30
for x
and 20
for y
, the program will output:
makefilez = 10
This indicates that the result of 30 - 20
is 10
.


Похожие вопросы
Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
Предметы
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili