Const n=4; m=5; var a:array [1..n,1..m] of integer; i,j,min,imin,jmin:integer; begin Randomize; Writeln('Исходный массив:'); for i:=1 to n do begin for j:=1 to m do begin a[i,j]:=random(21)-10; write(a[i,j]:6); end; writeln; end; min:=a[1,1]; imin:=1;jmin:=1; for i:=1 to n do for j:=1 to m do if a[i,j]<min then begin min:=a[i,j]; imin:=i; jmin:=j; end; writeln('min=a[',imin,',',jmin,']=',min); end.
#include
#include
int main()
{
int n;
int cnt = 0;
std: : cin > > n;
int **arr = new int*[n];
for(int i=0; i
{
arr[i] = new int[n];
for(int j=0; j
{
std: : cin > > arr[i][j];
//arr[i][j] = ++cnt;
}
}
cnt = 0;
while(cnt < n)
{
for(int i=0; i< (n-cnt); i++) std: : cout < < std: : setw(2) < < arr[cnt][i] < < " ";
std: : cout < < std: : endl;
cnt++;
}
for(int i=0; i
delete [] arr[i];
delete [] arr;
arr = nullptr;
system("pause");
return 0;
}
var a:array [1..n,1..m] of integer;
i,j,min,imin,jmin:integer;
begin
Randomize;
Writeln('Исходный массив:');
for i:=1 to n do
begin
for j:=1 to m do begin
a[i,j]:=random(21)-10;
write(a[i,j]:6);
end;
writeln;
end;
min:=a[1,1]; imin:=1;jmin:=1;
for i:=1 to n do
for j:=1 to m do
if a[i,j]<min then
begin min:=a[i,j]; imin:=i; jmin:=j; end;
writeln('min=a[',imin,',',jmin,']=',min);
end.
Пример:
Исходный массив:
5 8 2 -5 -4
1 -10 9 1 -4
8 2 -6 -4 -4
8 7 3 2 2
min=a[2,2]=-10