М
Молодежь
К
Компьютеры-и-электроника
Д
Дом-и-сад
С
Стиль-и-уход-за-собой
П
Праздники-и-традиции
Т
Транспорт
П
Путешествия
С
Семейная-жизнь
Ф
Философия-и-религия
Б
Без категории
М
Мир-работы
Х
Хобби-и-рукоделие
И
Искусство-и-развлечения
В
Взаимоотношения
З
Здоровье
К
Кулинария-и-гостеприимство
Ф
Финансы-и-бизнес
П
Питомцы-и-животные
О
Образование
О
Образование-и-коммуникации
Vlad2691
Vlad2691
17.08.2022 11:19 •  Информатика

Пользователи вводят длину стороны треугольника, вывести на экран его площадь

👇
Ответ:
sashachadaev
sashachadaev
17.08.2022
// PascalABC.NET 3.3, сборка 1576 от 16.11.2017
// Внимание! Если программа не работает, обновите версию!

begin
var (a, b, c):= ReadReal3('a, b, c =');
var p:=(a + b + c)/2;
Writeln('S = ',sqrt(p*(p - a)*(p - b)*(p - c)):0:5);
end.
4,8(32 оценок)
Открыть все ответы
Ответ:
Дедушка91
Дедушка91
17.08.2022

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.

 

4,6(63 оценок)
Ответ:
anay3
anay3
17.08.2022

1) Не достаточно информации

2)

Program help1;
Uses Crt;
Var a : Array[1..3, 1..3] of Integer;
i, j, m : Integer;

Begin
ClrScr;

For i := 1 to 3 do
For j := 1 to 3 do
Begin
Write('Введи a[', i, ', ', j, ']: ');
Readln(a[i, j]);
End;

If a[1, 1] > 0 then
m := 4;
If a[1, 1] < 0 then
m := 7;

For i := 1 to 3 do
For j := 1 to 3 do
a[i, j] := a[i, j] * m;
End.

3)

Program help2;
Uses Crt;
Var s : String;
n, i : Byte;

Begin
ClrScr;

Write('Введи строку: ');
Readln(s);

n := 0;

For i := 1 to Length(s) do
if s[i] = '5' then
inc(n);

Write('Цифра 5 встречается ', n, ' раз');
End.

4,4(76 оценок)
Это интересно:
Новые ответы от MOGZ: Информатика
logo
Вход Регистрация
Что ты хочешь узнать?
Спроси Mozg
Открыть лучший ответ