pascal
Объяснение:
procedure sortmas(a: array of integer);
var i, j, min, ind: integer;
begin
for i := 0 to Length(a) - 2 do
begin
min := a[i]; ind := i;
for j := i + 1 to Length(a) - 1 do
if a[j] < min then
begin
min := a[j]; ind := j;
end;
a[ind] := a[i]; a[i] := min;
end;
end;
var a: array of integer;
n , i: integer;
begin
WriteLn('Введите размер массива: '); Read(n);
SetLength(a, n);
Randomize;
WriteLn('Содержимое массива:');
for i := 0 to Length(a) - 1 do
begin
a[i] := random(100);
Write(a[i], ', ');
end;
WriteLn;
sortmas(a);
WriteLn('Три минимальных элемента: ', a[0], ', ', a[1], ', ', a[2], ', ');
end.
sugarMass=50 #масса сахара
sugarCost=15 #стоимость сахара
flourMass=100 #масса муки
flourCost=8 #стоимость муки
meatMass=12 #масса мяса
meatCost=95 #стоимость мяса
fishMass=20 #масса рыбы
fishCost=70 #стоимость рыбы
totalCost=sugarMass*sugarCost+flourMass*flourCost+meatMass*meatCost+fishMass*fishCost #общая стоимость
totalMass=sugarMass+flourMass+meatMass+fishMass #общая масса
print('Общая стоимость товара - ' + str(totalCost) + 'грн')
print('Общая масса товара - ' + str(totalMass) + 'кг')
print('Стоимость сахара - '+str(sugarMass*sugarCost)+'грн')
print('Стоимость муки - '+str(flourMass*flourCost)+'грн')
print('Стоимость мяса - '+str(meatMass*meatCost)+'грн')
print('Стоимость рыбы - '+str(fishMass*fishCost)+'грн')