Дано целое число n. вывести все целые числа от 1 до n в обратном порядке pascal
Ответы на вопрос
n, i: integer;
begin
readln(n);
for i := n downto 1 do
write(i, ' ');
end.
Reversing Numbers in Pascal
To reverse and print all integers from 1 to a given integer *n* in Pascal, you can use a recursive function. Here's a sample Pascal code to achieve this:
```pascal program ReverseNumbers;
procedure PrintReverseNumbers(n: integer); begin if n > 0 then begin writeln(n); PrintReverseNumbers(n-1); end; end;
var input: integer; begin write('Enter a number: '); readln(input); PrintReverseNumbers(input); end. ```
In this code: 1. We define a procedure `PrintReverseNumbers` that takes an integer *n* as input. 2. Inside the procedure, we check if *n* is greater than 0. If it is, we print *n* and then call the procedure recursively with *n-1*. 3. We also have a `main` block where we read the input from the user and call the `PrintReverseNumbers` procedure with the input value.
This code will print all integers from *n* down to 1 in reverse order.
Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili
