Program zadacha;vara: array[1..7] of integer;i,min,max,nmin,nmax,sum: integer;beginwriteln('enter numbers');for i:=1 to 7 do read(a[i]);min:=a[1];nmin:=1;for i:=2 to 7 doif a[i]<min then beginmin:=a[i];nmin:=i;end;max:=a[1];nmax:=1;for i:=2 to 7 doif a[i]>max then beginmax:=a[i];nmax:=i;end;sum:=min+max;writeln('min=',min, ' N=',nmin);writeln('max=',max, ' N=',nmax);writeln('sum=',sum);end.
elyashatdinova
27.10.2021
Const n=8; var a:array[1..n,1..n] of integer; i,j,k,s,s1,si,dmin,smin:integer; begin Randomize; writeln('Исходный массив:'); for i:=1 to n do begin for j:=1 to n do begin a[i,j]:=random(50); write(a[i,j]:4); end; writeln; end; write('k = '); readln(k); s:=0; for j:=1 to n do s:=s+a[k,j]; writeln('s = ',s); dmin:=999999; smin:=999999; for i:=1 to n do if i<>k then begin s1:=0; for j:=1 to n do s1:=s1+a[i,j]; writeln('s',i,' = ',s1); if abs(s1-s)<dmin then begin dmin:=abs(s1-s); smin:=s1; si:=i; end; end; writeln('Номер строки = ',si,', smin = ',smin); end.
// PascalABC.NET 3.1, сборка 1219 от 16.04.2016 type Matrix=array[,] of integer;
procedure MatPrint(a:Matrix); begin var m:=Length(a,1)-1; for var i:=0 to Length(a,0)-1 do begin for var j:=0 to m do Write(a[i,j]:4); Writeln end end;
function IsEqual(a:Matrix; col:integer):boolean; begin var s:=sign(a[0,col]); for var i:=1 to Length(a,0)-1 do s+=sign(a[i,col]); if (s=0) then Result:=(a[0,col]<>0) else Result:=false end;
procedure DeleteCol(var a:Matrix; col:integer); begin var n:=Length(a,0)-1; var m:=Length(a,1)-1; for var j:=col+1 to Length(a,1)-1 do for var i:=0 to n do a[i,j-1]:=a[i,j]; SetLength(a,n+1,m) end;
begin var n:=ReadInteger('Строк:'); var m:=ReadInteger('Столбцов:'); var a:=MatrixRandom(n,m,-99,99); Writeln('Исходная матрица'); MatPrint(a); for var j:=Length(a,1)-1 downto 0 do if IsEqual(a,j) then DeleteCol(a,j); Writeln('Результирующая матрица'); MatPrint(a); end.