type
arr_2d = array[1 .. 10, 1 .. 10] of integer;
arr_1d = array[1 .. 100] of integer;
var
mx: arr_2d;
...
arr_1d(mx)[1] := 10;
...
type
arr_2d = array[1 .. 10, 1 .. 10] of integer;
arr_1d = array[1 .. 100] of integer;
var
mx: arr_2d;
arr: arr_1d absolute mx; { <--- физически накладываешь массив на матрицу }
program practuka;
uses crt;
type
arr_2d= array[1 .. 2, 1 .. 2] of integer;
arr_1d= array[1 .. 4] of integer;
var f: text;
x,i,k,j:integer;
mx: arr_2d;
arr: arr_1d absolute mx;
sort: boolean;
begin
assign(f, 'matr.txt');
rewrite(f);
clrscr;
for i:=1 to 4 do
begin
write('3HA4EHUE',i,':');
read(arr[i]);
writeln;
end;
repeat
sort:=true;
for i := 1 to 3 do
if arr[i]<arr[i+1] then
begin
x:=arr[i];
arr[i]:=arr[i+1];
arr[i+1]:=x;
sort:=false;
end;
until sort;
writeln;
for i:=1 to 4 do
begin
k := (i-1) div 2 + 1;
j := i-(k-1)*2;
writeln(f,'(',arr[i],')','(',k,',',j,')'); {в файле выводятся координаты}
end;
close(f);
end.
program practuka;
uses crt;
type
arr_2d= array[1 .. 2, 1 .. 2] of integer;
arr_1d= array[1 .. 4] of integer;
var f: text;
x,i,k,j:integer;
mx: arr_2d;
arr: arr_1d absolute mx;
indexes: arr_1d;
sort: boolean;
begin
assign(f, 'matr.txt');
rewrite(f);
clrscr;
for i:=1 to 4 do
begin
write('3HA4EHUE',i,':');
read(arr[i]);
writeln;
indexes[i] := i;
end;
repeat
sort:=true;
for i := 1 to 3 do
if arr[i]<arr[i+1] then
begin
x:=arr[i];
arr[i]:=arr[i+1];
arr[i+1]:=x;
x := indexes[i];
indexes[i] := indexes[i+1];
indexes[i+1] := x;
sort:=false;
end;
until sort;
writeln;
for i:=1 to 4 do
begin
k := (indexes[i]-1) div 2 + 1;
j := indexes[i]-(k-1)*2;
writeln(f,'(',arr[i],')','(',k,',',j,')');
end;
close(f);
end.
program practuka;
uses crt;
type
arr_2d= array[1 .. 2, 1 .. 2] of integer;
arr_1d= array[1 .. 4] of integer;
var f: text;
x,i,k,j:integer;
mx: arr_2d;
arr: arr_1d absolute mx;
index: arr_1d;
sort: boolean;
begin
assign(f, 'matr.txt');
rewrite(f);
clrscr;
for i:=1 to 4 do
begin
write('3HA4EHUE',i,':');
read(arr[i]);
writeln;
index[i]:=i; {инициализируем индексы}
end;
repeat
sort:=true;
for i := 1 to 3 do
if arr[i]<arr[i+1] then
begin
x:=arr[i];
arr[i]:=arr[i+1];
arr[i+1]:=x;
sort:=false;
x:=index[i]; {также меняем местами и индексы}
index[i]:=index[i+1];
index[i+1]:=x;
end;
until sort;
writeln;
for i:=1 to 4 do
begin
k := (index[i]-1) div 2 + 1; {вместо i используем индексный массив}
j := index[i]-(k-1)*2;
writeln(f,'(',arr[i],')','(',k,',',j,')'); {в файле выводятся координаты}
end;
close(f);
end.