Опубликовано 1 год назад по предмету Информатика от 20SASHULYA08

Помогите пожалуйста! На вход программы поступает натуральное число, не превышающее 10^9 Нужно написать программу, которая выводит на экран максимальную цифру числа, меньшую 5 Если в числе нет цифр, меньших 5, требуется на экран вывести «NO». В приведённой программе есть ошибки. var N, d, m: longint; begin readln(N); m := N mod 10; while N > 0 do begin d := N mod 10; if d < 5 then if d > m then m := d; N := N div 10; end; if m = 0 then writeln('NO') else writeln( m ) end. Последовательно выполните следующее. 1 Напишите, что выведет эта программа при вводе числа 157 2 Укажите наибольшее трёхзначное значение входной переменной n, при вводе которого программа выведет правильный ответ. Укажите это ответ. 3 Найдите в программе все ошибки (их может быть одна или несколько). Для каждой ошибки выпишите строку, в которой она допущена, и приведите эту же строку в исправленном виде.

  1. Ответ
    Ответ дан archery
    1) 7  - изза начального присвоение m2) 994. 4 соответствует условию, остальные числа лишь максимизируют число3)var    N, d, m: longint;begin    readln(N);    {m := N mod 10; ошибочная строка}    m:=-1; {N mod 10 - может не удовлетворять условию, 0 - может и удовлетворять условию }    while N > 0 do     begin        d := N mod 10;        if d < 5 then            if d > m then m := d;        N := N div 10;    end;    {if m = 0 then ошибочная строка}    if m = -1 then {если в цикле m так не разу и не поменялась}        writeln('NO')    else writeln(m);end.
Не тот ответ, который вам нужен?
Найди нужный
Самые новые вопросы
Английский язык - 3 месяца назад

College reconstruction (1) our life goes on and nothing can stay the same for a long time without being changed to satisfy modern needs. the college plans to modernize its current site in a multimillion pound investment to upgrade its buildings and create a new campus. the college has secured support and funding for the project and is now looking for a suitable developer to take the project forward. although no formal plans have been filed at this stage, the college administration aims to reconstruct the existing location with new buildings in one area and sell the remaining land for further development. the total amount of spending for the whole project will be about £40 million. (2) we are aware of people’s worries concerning the redevelopment of the site, but we cannot continue in the present buildings in the long term. they have become tired and unworkable and are now proving very costly to maintain – that is money that should be spent directly on teaching and learning. the buildings do not meet our needs for the 21st century and our students’ requirements. frankly speaking they are outdated. (3) the quality of the teaching and learning at the college will always be the most important thing. that’s why we intend to create a brand new college campus. we want our students to have the opportunity to learn in modern, up-to-date facilities. this investment is timed to make sure that our future students will also have top-class facilities. (4) during the creation of our new campus, we aim to ensure that the reconstruction takes place away from any buildings that will still be in use. an appraisal of all the existing buildings will be carried out to make sure that they are capable of providing a suitable learning environment until the new buildings are complete. if necessary, some money will be available to ensure that these buildings remain fit-for-purpose until the new buildings are ready. (5) we are determined to work closely with our local neighbors on this project. though there will be a formal public consultation process as part of the planning procedures, we will also be inviting our immediate local residents to more informal meetings where we can pay our full attention to their views and opinions. our consultants are beginning to work on putting together plans that will give us an idea of what the new campus will look like. we will consult closely with local people as the project progresses. our intention is to create a college that benefits everyone. задание 9. cоставьте 10 вопросов различного типа к любым предложениям из текста.

Задай вопрос