
Вопрос задан 26.02.2019 в 09:00.
Предмет Информатика.
Спрашивает Истранина Анастасия.
1.Вычислите сумму элементов массива. Элементы массива вводятся с клавиатуры. Составить алгоритм
решения задачи и написать программный код на языке Паскаль. 2. Составьте алгоритм и программу нахождения полупроизведения двух чисел. Составить алгоритм решения задачи и написать программный код на языке Паскаль. 3.Составьте программу,реализующую эпизод применения компьютера в книжном магазине. Компьютер запрашивает стоимость книг,сумму денег,внесённую покупателем. Если здачи не требуется,печатает на экране"Спасибо";если денег внесено больше,то печатает "Возьмите сдачу" и сумму сдачи;если денег недостаточно ,то печатает об этом сообщение и указывает размер недостающей суммы. Составить алгоритм решения задачи и написать программный код на языке Паскаль.

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

Отвечает Староконь Алексей.
1.
program z_1;
var i,s;intger;
a:array [1..50] of integer;
begin
for i:=1 to 50 do
begin
readln(a[i]);
s:=s+a[i];
end;
writeln(s);
end.
2.
program z_2;
var c1,c2,pp:integer;
begin
readln(c1);
readln(c2);
pp:=round((c1*c2)/2);//полупроизведение двух чисел
writeln(pp);
end.
3.
program z_3;
var k,v,s:integer;
begin
readln(k);//Стоимость книги
readln(v);//Внесено денег
if k=v then
writeln('Спасибо!')
else
if k<v then
writeln('Возьмите сдачу : ',v-k)
else
writeln('Недостаточно средств : ',k-v);
end.
program z_1;
var i,s;intger;
a:array [1..50] of integer;
begin
for i:=1 to 50 do
begin
readln(a[i]);
s:=s+a[i];
end;
writeln(s);
end.
2.
program z_2;
var c1,c2,pp:integer;
begin
readln(c1);
readln(c2);
pp:=round((c1*c2)/2);//полупроизведение двух чисел
writeln(pp);
end.
3.
program z_3;
var k,v,s:integer;
begin
readln(k);//Стоимость книги
readln(v);//Внесено денег
if k=v then
writeln('Спасибо!')
else
if k<v then
writeln('Возьмите сдачу : ',v-k)
else
writeln('Недостаточно средств : ',k-v);
end.



Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.
1. To calculate the sum of elements in an array in Pascal, you can follow the algorithm below:
Algorithm:
1. Declare an array variable to store the elements. 2. Prompt the user to enter the number of elements in the array. 3. Read the input and store it in a variable. 4. Declare a variable to store the sum and initialize it to 0. 5. Use a loop to iterate through each element of the array. 6. Prompt the user to enter each element of the array. 7. Read the input and add it to the sum variable. 8. After the loop ends, display the sum of the elements.Pascal Code:
```pascal program SumOfArrayElements; var arr: array of Integer; numElements, i, sum: Integer; begin Write('Enter the number of elements in the array: '); Readln(numElements); SetLength(arr, numElements); sum := 0; for i := 0 to numElements - 1 do begin Write('Enter element ', i + 1, ': '); Readln(arr[i]); sum := sum + arr[i]; end; Writeln('The sum of the elements is: ', sum); end. ```2. To find the half-product of two numbers in Pascal, you can use the following algorithm:
Algorithm:
1. Declare two variables to store the two numbers. 2. Prompt the user to enter the first number. 3. Read the input and store it in the first variable. 4. Prompt the user to enter the second number. 5. Read the input and store it in the second variable. 6. Calculate the half-product by multiplying the two numbers and dividing the result by 2. 7. Display the half-product.Pascal Code:
```pascal program HalfProduct; var num1, num2, halfProduct: Real; begin Write('Enter the first number: '); Readln(num1); Write('Enter the second number: '); Readln(num2); halfProduct := (num1 * num2) / 2; Writeln('The half-product is: ', halfProduct); end. ```3. To implement a computer program for a bookstore scenario in Pascal, you can use the following algorithm:
Algorithm:
1. Declare variables to store the book price, amount paid by the customer, and change. 2. Prompt the user to enter the book price. 3. Read the input and store it in the book price variable. 4. Prompt the user to enter the amount paid by the customer. 5. Read the input and store it in the amount paid variable. 6. Calculate the change by subtracting the book price from the amount paid. 7. Use conditional statements to check the value of the change: - If the change is zero, display "Thank you." - If the change is positive, display "Take your change" and the amount of change. - If the change is negative, display a message indicating the amount of the shortfall. 8. End the program.Pascal Code:
```pascal program Bookstore; var bookPrice, amountPaid, change: Real; begin Write('Enter the price of the book: '); Readln(bookPrice); Write('Enter the amount paid by the customer: '); Readln(amountPaid); change := amountPaid - bookPrice; if change = 0 then Writeln('Thank you.') else if change > 0 then Writeln('Take your change: ', change:0:2) else Writeln('Insufficient payment. You need an additional amount of ', -change:0:2); end. ```Please note that the above code snippets are written in Pascal and can be executed in a Pascal compiler or IDE.


Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
Предметы
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili