Даны натуральные числа n,m и двумерный массив разиером nXm. Составте программу, которая находит сумму элементов той строки, в которой расположен элемент с наименьшим сначением. Предпологается, что такой элемент единственный.(программа в паскале)
program SumMinRow; const MAX = 100; var n, m, i, j, minElement, sum, rowWithMinElement: integer; arr: array[1..MAX, 1..MAX] of integer; begin write('Enter the number of rows: '); readln(n); write('Enter the number of columns: '); readln(m);
for i := 1 to n do for j := 1 to m do begin write('Enter element [', i, ',', j, ']: '); readln(arr[i, j]); end;
minElement := arr[1, 1]; rowWithMinElement := 1;
for i := 1 to n do for j := 1 to m do if arr[i, j] < minElement then begin minElement := arr[i, j]; rowWithMinElement := i; end;
sum := 0; for j := 1 to m do sum := sum + arr[rowWithMinElement, j];
writeln('Sum of elements in the row with the smallest element: ', sum); end.
program SumMinRow;
const
MAX = 100;
var
n, m, i, j, minElement, sum, rowWithMinElement: integer;
arr: array[1..MAX, 1..MAX] of integer;
begin
write('Enter the number of rows: ');
readln(n);
write('Enter the number of columns: ');
readln(m);
for i := 1 to n do
for j := 1 to m do
begin
write('Enter element [', i, ',', j, ']: ');
readln(arr[i, j]);
end;
minElement := arr[1, 1];
rowWithMinElement := 1;
for i := 1 to n do
for j := 1 to m do
if arr[i, j] < minElement then
begin
minElement := arr[i, j];
rowWithMinElement := i;
end;
sum := 0;
for j := 1 to m do
sum := sum + arr[rowWithMinElement, j];
writeln('Sum of elements in the row with the smallest element: ', sum);
end.