Вопрос задан 05.11.2023 в 00:58. Предмет Информатика. Спрашивает Соломатин Влад.

Помогите пожалуйста написать надо на проге Pascal напишите пропоследовательности грамму которая в

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

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

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

var

 i,max,n:integer;

begin  

 max:=0;  

 readln(n);

 for i:=1 to n do

   begin

     readln(n);

     if (n>max) and (n mod 10 = 8) then

       max:=n;

   end;

 writeln;

 writeln(max);

end.

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

To write a program in Pascal that determines the maximum number ending in 8 in a sequence of natural numbers, you can follow these steps:

1. Declare the necessary variables: - `n`: an integer to store the number of elements in the sequence - `sequence`: an array of integers to store the sequence of numbers - `maxNumber`: an integer to store the maximum number ending in 8

2. Read the number of elements in the sequence from the user: - Use the `ReadLn` function to read the value into the variable `n`

3. Read the sequence of numbers from the user: - Use a loop to read `n` numbers into the `sequence` array using the `ReadLn` function

4. Initialize `maxNumber` to a value that is guaranteed to be less than any number in the sequence (e.g., 0).

5. Iterate over the sequence of numbers: - Use a loop to iterate over each number in the `sequence` array - Check if the current number ends in 8 and is greater than `maxNumber` - If it is, update `maxNumber` with the current number

6. Print the maximum number ending in 8: - Use the `WriteLn` function to output the value of `maxNumber`

Here's an example implementation of the program in Pascal

0 0

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

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

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

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