program PercentagesArray;
uses
SysUtils;
const
ROWS = 3;
COLS = 5;
PERCENT_INCREASE = 0.05;
MIN_VALUE = 0.0;
MAX_VALUE = 100.0;
type
TMatrix = array[1..ROWS, 1..COLS] of real;
var
percentages: TMatrix;
i, j: integer;
function addSPercent(percent: real): real;
begin
addSPercent := percent * (1 + PERCENT_INCREASE);
end;
function getRandomReal(min, max: real): real;
begin
getRandomReal := min + random * (max - min);
end;
procedure fillArray(var matrix: TMatrix);
begin
randomize;
for i := 1 to ROWS do
for j := 1 to COLS do
matrix[i, j] := getRandomReal(MIN_VALUE, MAX_VALUE);
end;
procedure processArray(var matrix: TMatrix);
begin
for i := 1 to ROWS do
for j := 1 to COLS do
matrix[i, j] := addSPercent(matrix[i, j]);
end;
procedure printArray(const matrix: TMatrix; const title: string);
const
FIELD_WIDTH = 10;
DECIMALS = 2;
begin
writeln(title);
writeln('=' * (COLS * (FIELD_WIDTH + 1)));
for i := 1 to ROWS do
begin
for j := 1 to COLS do
write(matrix[i, j]:FIELD_WIDTH:DECIMALS, ' ');
writeln;
end;
writeln('=' * (COLS * (FIELD_WIDTH + 1)));
end;
begin
fillArray(percentages);
printArray(percentages, 'Initial array:');
processArray(percentages);
writeln;
printArray(percentages, 'Array after adding 5%:');
readln; // Pause to see results
end.
program PercentArray;
var
percentages: array[1..3, 1..5] of real;
i, j: integer;
function addSPercent(percent: real): real;
begin
addSPercent := percent * 1.05;
end;
begin
Randomize;
// Заполнение массива случайными числами от 0.0 до 100.0
for i := 1 to 3 do
for j := 1 to 5 do
percentages[i][j] := Random * 100.0;
// Обработка элементов массива функцией addSPercent
for i := 1 to 3 do
for j := 1 to 5 do
percentages[i][j] := addSPercent(percentages[i][j]);
// Вывод массива на экран
Writeln('Массив после увеличения на 5%:');
for i := 1 to 3 do
begin
for j := 1 to 5 do
Write(percentages[i][j]:0:2, ' ');
Writeln;
end;
end.
program Percentages;
type
Matrix = array[1..3, 1..5] of Real;
function addSPercent(percent: Real): Real;
begin
addSPercent := percent * 1.05;
end;
var
percentages: Matrix;
i, j: Integer;
begin
Randomize;
for i := 1 to 3 do
for j := 1 to 5 do
percentages[i, j] := Random * 100;
for i := 1 to 3 do
for j := 1 to 5 do
percentages[i, j] := addSPercent(percentages[i, j]);
for i := 1 to 3 do
begin
for j := 1 to 5 do
Write(percentages[i, j]:0:2, ' ');
Writeln;
end;
end.