Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
19
Добавлен:
02.05.2014
Размер:
1.92 Кб
Скачать
Program matrix;
Uses crt;
Var
ind, s, i, j, m, n, k, l, min, max, x, xmin: integer;
a: array[1..100,1..100] of integer;
b: array[1..100,1..100] of integer;
c: array[1..100,1..100] of integer;



begin
clrscr;
write('vvedite chislo strok matrici A '); readln (n);
write('vvedite chislo stolbcov matrici A '); readln (m);
write('vvedite chislo strok matrici B '); readln (k);
write('vvedite chislo stolbcov matrici B '); readln (l);
clrscr;
write('vvedite postrochno matricu A ');
for i:=1 to n do
begin
writeln('');
for j:=1 to m do
begin
write(' A[',i,',',j,']= '); read(x); a[i,j]:=x;
end;
end;
clrscr;
write('vvedite postrochno matricu B ');
for i:=1 to k do
begin
writeln('');
for j:=1 to l do
begin
write(' B[',i,',',j,']= '); read(x); b[i,j]:=x;
end;
end;

min:=9999;
for i:=1 to n do
if a[i,1]<min then
begin
min:=a[i,1];
xmin:=i;
ind:=1;
end;

for i:=1 to k do
if b[i,1]<min then
begin
min:=b[i,1];
xmin:=i;
ind:=2;
end;

s:=0;
if ind=1 then
begin
for j:=1 to m do s:=s+a[xmin,j];
end;
if ind=2 then
begin
for j:=1 to l do s:=s+a[xmin,j];
end;
clrscr;
writeln('summa elementov stroki, imeushej pervij minimalnij element, ravna ',s);
writeln('');
writeln('matrica A: ');
for i:=1 to n do
begin
writeln('');
for j:=1 to m do
write(a[i,j],' ');
end;
writeln('');writeln('');
writeln('matrica B: ');
for i:=1 to k do
begin
writeln('');
for j:=1 to l do
write(b[i,j],' ');
end;

if (n=k)and(m=l) then
begin
max:=-9999;
writeln('');writeln('');
writeln('summa matric A+B= ');
for i:=1 to k do
begin
writeln('');
for j:=1 to l do
begin
c[i,j]:=b[i,j]+a[i,j];
write(c[i,j],' ');
if c[i,j]>max then max:=c[i,j];
end;end;
writeln('');writeln('');
writeln('maximalnij element summi matric raven ',max);
end
else
begin
writeln('');
writeln('matrici imeut raznuu razmernict, summu ne ishem.');
end;
Readkey;
end.
Соседние файлы в папке Равиль