А как заставить ее работать в прямоугольном массиве?
Код
PROGRAM KR1;
CONST
n=5;
m=5;
k=100;
r=100;
VAR
B:array[1..r] of integer;
A:array[1..n,1..m] of real;
i,j,c,mm,nn,mmm,nnn:integer;
Procedure FINDINT;
begin
B[c]:=Trunc(A[i,j]);
write(B[c],' ');
c:=c+1;
end;
BEGIN
Writeln;
write('-------------------------------------------------');
Writeln;
Write('generatsiya massiva');
begin {nachalo generatsii massiva}
randomize;
for i:=1 to n do
for j:=1 to m do
A[i,j]:=random(k);
end;{konets generatsii massiva}
i:=1;
j:=1;
Writeln;
Writeln('-------------------------------------------------');
while i<=m do
begin
writeln;
while j<=n do
begin
write(A[i,j]:1:2,' ');
j:=j+1
end;
i:=i+1;
j:=1;
end;
Writeln;
write('-------------------------------------------------');
Writeln;
write('massiv sgenerirovan');
Writeln;
write('-------------------------------------------------');
writeln;
i:=1;
j:=1;
c:=1;
mmm:=1;
nnn:=1;
mm:=m;
nn:=n;
while mmm<=mm do {glavniy cikl}
begin
while nnn<=nn do
begin
while j<=mm do {vpravo}
begin
FINDINT; j:=j+1;
end;
j:=mm;
nnn:=nnn+1;
i:=nnn;
while i<=nn do {vniz}
begin
FINDINT; i:=i+1;
end;
i:=nn;
mm:=mm-1;
j:=mm;
while j>=mmm do {vlevo}
begin
FINDINT; j:=j-1;
end;
j:=mmm;
nn:=nn-1;
i:=nn;
while i>=nnn do {vverh}
begin
FINDINT; i:=i-1;
end;
i:=nnn;
mmm:=mmm+1;
j:=mmm;
end;
end;
Writeln;
write ('SUMMA CHLENOV=',c-1);
ReadLn;
END.
CONST
n=5;
m=5;
k=100;
r=100;
VAR
B:array[1..r] of integer;
A:array[1..n,1..m] of real;
i,j,c,mm,nn,mmm,nnn:integer;
Procedure FINDINT;
begin
B[c]:=Trunc(A[i,j]);
write(B[c],' ');
c:=c+1;
end;
BEGIN
Writeln;
write('-------------------------------------------------');
Writeln;
Write('generatsiya massiva');
begin {nachalo generatsii massiva}
randomize;
for i:=1 to n do
for j:=1 to m do
A[i,j]:=random(k);
end;{konets generatsii massiva}
i:=1;
j:=1;
Writeln;
Writeln('-------------------------------------------------');
while i<=m do
begin
writeln;
while j<=n do
begin
write(A[i,j]:1:2,' ');
j:=j+1
end;
i:=i+1;
j:=1;
end;
Writeln;
write('-------------------------------------------------');
Writeln;
write('massiv sgenerirovan');
Writeln;
write('-------------------------------------------------');
writeln;
i:=1;
j:=1;
c:=1;
mmm:=1;
nnn:=1;
mm:=m;
nn:=n;
while mmm<=mm do {glavniy cikl}
begin
while nnn<=nn do
begin
while j<=mm do {vpravo}
begin
FINDINT; j:=j+1;
end;
j:=mm;
nnn:=nnn+1;
i:=nnn;
while i<=nn do {vniz}
begin
FINDINT; i:=i+1;
end;
i:=nn;
mm:=mm-1;
j:=mm;
while j>=mmm do {vlevo}
begin
FINDINT; j:=j-1;
end;
j:=mmm;
nn:=nn-1;
i:=nn;
while i>=nnn do {vverh}
begin
FINDINT; i:=i-1;
end;
i:=nnn;
mmm:=mmm+1;
j:=mmm;
end;
end;
Writeln;
write ('SUMMA CHLENOV=',c-1);
ReadLn;
END.