Программа:
const n=5; m=6;
var
a:array[1..n,1..m] of integer;
i,j,s,min,k:integer;
begin
Randomize;
writeln('Исходный массив:');
for i:=1 to n do
for j:=1 to m do
a[i,j]:=random(100);
write(a[i,j]:4);
end;
writeln;
min:=0; k:=1;
for j:=1 to m do min:=min+a[1,j];
writeln('s1 = ',min);
for i:=2 to n do
s:=0;
for j:=1 to m do s:=s+a[i,j];
writeln('s',i,' = ',s);
if s<min then begin min:=s; k:=i; end;
writeln('min сумма = ',min,' (',k,'-я строка)');
end.
Пример:
Исходный массив:
24 61 29 35 82 8
98 58 55 2 11 35
14 46 59 55 79 8
4 25 4 48 83 49
96 27 56 87 91 63
s1 = 239
s2 = 259
s3 = 261
s4 = 213
s5 = 420
min сумма = 213 (4-я строка)
#include <iostream>
#include <cmath>
int main()
{
//setlocale(LC_ALL, "Russian");
float
a, b, c, d, e, f, g, h;
std::cin >> a >> b >> c >> d >> e >> f >> g >> h;
d = a + b;
e = c - 42;
f = d * (b + e);
g = (d * e) / (a + b + c);
h = sqrt(b - c);
std::cout << "d = " << d << std::endl
<< "e = " << e << std::endl
<< "f = " << f << std::endl
<< "g = " << g << std::endl
<< "h = " << h << std::endl;
system("PAUSE >> void");
return 0;
}
Программа:
const n=5; m=6;
var
a:array[1..n,1..m] of integer;
i,j,s,min,k:integer;
begin
Randomize;
writeln('Исходный массив:');
for i:=1 to n do
begin
for j:=1 to m do
begin
a[i,j]:=random(100);
write(a[i,j]:4);
end;
writeln;
end;
min:=0; k:=1;
for j:=1 to m do min:=min+a[1,j];
writeln('s1 = ',min);
for i:=2 to n do
begin
s:=0;
for j:=1 to m do s:=s+a[i,j];
writeln('s',i,' = ',s);
if s<min then begin min:=s; k:=i; end;
end;
writeln('min сумма = ',min,' (',k,'-я строка)');
end.
Пример:
Исходный массив:
24 61 29 35 82 8
98 58 55 2 11 35
14 46 59 55 79 8
4 25 4 48 83 49
96 27 56 87 91 63
s1 = 239
s2 = 259
s3 = 261
s4 = 213
s5 = 420
min сумма = 213 (4-я строка)
#include <iostream>
#include <cmath>
int main()
{
//setlocale(LC_ALL, "Russian");
float
a, b, c, d, e, f, g, h;
std::cin >> a >> b >> c >> d >> e >> f >> g >> h;
d = a + b;
e = c - 42;
f = d * (b + e);
g = (d * e) / (a + b + c);
h = sqrt(b - c);
std::cout << "d = " << d << std::endl
<< "e = " << e << std::endl
<< "f = " << f << std::endl
<< "g = " << g << std::endl
<< "h = " << h << std::endl;
system("PAUSE >> void");
return 0;
}