Паскаль. 1. Буратино купил n учебников по a сольдо и m ручек по b карандашей по n сольдо. a, b, m, n задаются с клавиатуры. Рассчитать общую стоимость покупки. 2. Среди трёх введённых чисел вывести количество положительных. 3. Найти сумму всех чисел от a до b. 4. Сгенерировать массив. Подсчитать число положительных чисел.

17 Авг 2021 в 19:46
213 +1
0
Ответы
1

program Lab3_Pascal;
uses crt;

var
a, b, m, n, cost, positiveCount, i, sum: integer;
arr: array1..101..101..10 of integer;

begin
// Ввод данных
write′EnterthenumberoftextbooksboughtbyBuratino:′'Enter the number of textbooks bought by Buratino: 'EnterthenumberoftextbooksboughtbyBuratino:;
readlnnnn;
write′Enterthecostofeachtextbook:′'Enter the cost of each textbook: 'Enterthecostofeachtextbook:;
readlnaaa;
write′EnterthenumberofpensboughtbyBuratino:′'Enter the number of pens bought by Buratino: 'EnterthenumberofpensboughtbyBuratino:;
readlnmmm;
write′Enterthecostofeachpen:′'Enter the cost of each pen: 'Enterthecostofeachpen:;
readlnbbb;

// Вычисляем общую стоимость покупки
cost := na + mb;
writeln′Thetotalcostofthepurchaseis:′,cost'The total cost of the purchase is: ', costThetotalcostofthepurchaseis:,cost;

// Определяем количество положительных чисел среди трех введенных
positiveCount := 0;
write′Enterthreenumbers:′'Enter three numbers: 'Enterthreenumbers:;
for i := 1 to 3 do
begin
readlnarr[i]arr[i]arr[i];
if arriii > 0 then
positiveCount := positiveCount + 1;
end;
writeln′Thenumberofpositivenumbersenteredis:′,positiveCount'The number of positive numbers entered is: ', positiveCountThenumberofpositivenumbersenteredis:,positiveCount;

// Вычисляем сумму всех чисел от a до b
sum := 0;
write′Entertwonumbers(aandb):′'Enter two numbers (a and b): 'Entertwonumbers(aandb):;
readlnaaa;
readlnbbb;
for i := a to b do
begin
sum := sum + i;
end;
writeln′Thesumofallnumbersfrom′,a,′to′,b,′is:′,sum'The sum of all numbers from ', a, ' to ', b, ' is: ', sumThesumofallnumbersfrom,a,to,b,is:,sum;

// Генерируем массив и считаем количество положительных чисел
for i := 1 to 10 do
begin
arriii := random202020 - 10;
if arriii > 0 then
positiveCount := positiveCount + 1;
end;
writeln′Thenumberofpositivenumbersinthearrayis:′,positiveCount'The number of positive numbers in the array is: ', positiveCountThenumberofpositivenumbersinthearrayis:,positiveCount;

end.

17 Апр 2024 в 13:19
Не можешь разобраться в этой теме?
Обратись за помощью к экспертам
Гарантированные бесплатные доработки в течение 1 года
Быстрое выполнение от 2 часов
Проверка работы на плагиат
Поможем написать учебную работу
Прямой эфир