program matrixToArray;
varmatrix: array[1..3, 1..4] of integer;arrayResult: array[1..12] of integer;i, j, k: integer;
begin// Fill the matrix with random numbersfor i := 1 to 3 dobeginfor j := 1 to 4 dobeginmatrix[i, j] := Random(100);end;end;
// Display the matrixwriteln('Matrix:');for i := 1 to 3 dobeginfor j := 1 to 4 dobeginwrite(matrix[i, j], ' ');end;writeln;end;
// Fill the one-dimensional arrayk := 1;for i := 1 to 3 dobeginfor j := 1 to 4 dobeginarrayResult[k] := matrix[i, j];k := k + 1;end;end;
// Display the one-dimensional arraywriteln('One-dimensional array:');for i := 1 to 12 dobeginwrite(arrayResult[i], ' ');end;
end.
program matrixToArray;
var
matrix: array[1..3, 1..4] of integer;
arrayResult: array[1..12] of integer;
i, j, k: integer;
begin
// Fill the matrix with random numbers
for i := 1 to 3 do
begin
for j := 1 to 4 do
begin
matrix[i, j] := Random(100);
end;
end;
// Display the matrix
writeln('Matrix:');
for i := 1 to 3 do
begin
for j := 1 to 4 do
begin
write(matrix[i, j], ' ');
end;
writeln;
end;
// Fill the one-dimensional array
k := 1;
for i := 1 to 3 do
begin
for j := 1 to 4 do
begin
arrayResult[k] := matrix[i, j];
k := k + 1;
end;
end;
// Display the one-dimensional array
writeln('One-dimensional array:');
for i := 1 to 12 do
begin
write(arrayResult[i], ' ');
end;
end.