В
Все
Б
Биология
Б
Беларуская мова
У
Українська мова
А
Алгебра
Р
Русский язык
О
ОБЖ
И
История
Ф
Физика
Қ
Қазақ тiлi
О
Окружающий мир
Э
Экономика
Н
Немецкий язык
Х
Химия
П
Право
П
Психология
Д
Другие предметы
Л
Литература
Г
География
Ф
Французский язык
М
Математика
М
Музыка
А
Английский язык
М
МХК
У
Українська література
И
Информатика
О
Обществознание
Г
Геометрия
romatopovsky
romatopovsky
22.02.2020 17:34 •  Информатика

разработайте алгоритм и программу вычисления выражения y=1/x+2 для паскала . Хочу типо Var y,x: integer; так далее ...

Показать ответ
Ответ:
alexandra2981278247
alexandra2981278247
23.09.2022 15:33
Const n=20;
type omas=array[1..n] of integer;
Procedure Del (var z:omas; k:byte); 
var i:byte; 
begin 
for i:=k to n-1 do z[i]:=z[i+1]; 
z[n]:=0; 
end; 
var a:omas; i,b:integer;
begin
Randomize;
for i:=1 to n do
 begin
 a[i]:=random(20);
 write(a[i]:4);
 end;
writeln;
b:=6;
i:=1;
while (i<=n)and(a[i]<>b) do i:=i+1;
if i<=n then
  begin
  Del(a,i);
 writeln('Размерность массива = ',n-1);
 for i:=1 to n-1 do write(a[i]:4);
 writeln;
 end  else writeln('Массив не изменился');
end.
Пример:
  12  13   6   7  17   1  18  17   3   2  12   3  16   6   7  13   0   2   5  18
Размерность массива = 19
  12  13   7  17   1  18  17   3   2  12   3  16   6   7  13   0   2   5  18
0,0(0 оценок)
Ответ:
Nemiroffdenisa
Nemiroffdenisa
24.05.2021 17:43
Romanf romanf отличник 2013-01-10t16: 13: 22+00: 00 1. подумать над алгоритмом 2. вот сам алгоритм: а. спросить у пользователя значения б. расчитать ответ в. выдать ответ на экран 3. написать код в паскале 4. исправить ошибки компиляции 5. протестировать, вводить разные числа 6. обнаружила, что если вводить числа наугад ответ получается отрицательным иногда 7. вставить код проверки введенных пользователем значений 8. убрать ошибки компиляции 9. протестировать 10. готово а вот и сама программа: program aerobus; uses crt; const totalplace = 160; var businessplaces, economyplaces: integer; businessprice, economyprice: real; totalcharge: real; a,b: integer; correctinput: boolean; begin clrscr; businessplaces: =totalplace div 4; economyplaces: = totalplace - businessplaces; writeln('business places count: ', businessplaces); writeln('economy places count: ', economyplaces); correctinput: =false; while not correctinput do begin write('please input business class ticket price: '); readln(businessprice); if(businessprice> 0) then begin correctinput: =true; end else begin writeln('the price should be a positive number, please try again'); end; end; economyprice: =businessprice/2; writeln('economy ticket price is: ', economyprice: 0: 2); correctinput: =false; while not correctinput do begin write('how many business tickets are left? : '); readln(a); if(a> =0) and (a< =businessplaces)then correctinput: =true; if(a< 0) then begin writeln('please input a positive number or 0, please try again'); end; if(a> businessplaces) then begin writeln('please input a number which is less or equal to the tolal business place count, please try again'); end; end; correctinput: =false; while not correctinput do begin write('how many economy tickets are left? : '); readln(b); if(b> =0) and (b< =economyplaces)then correctinput: =true; if(b< 0) then begin writeln('please input a positive number or 0, please try again'); end; if(b> economyplaces) then begin writeln('please input a number which is less or equal to the tolal economy place count, please try again'); end; end; totalcharge: =(businessplaces-a)*businessprice; totalcharge: =totalcharge+(economyplaces-b)*economyprice; writeln('the total charge is: ', totalcharge: 0: 2); writeln; writeln('press enter to exit'); readln; end.
0,0(0 оценок)
Популярные вопросы: Информатика
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота