PROCEDURE aa;
CONST
max=20;
VAR
a:array[0..max,0..max] of integer;
m,i1,i2:integer;
PROCEDURE ww(k,n:integer);
var
i,j:integer;
begin
if n=2
then begin
a[k,0]:=k; a[k+1,0]:=k+1;
a[k,1]:=k+1; a[k+1,1]:=k;
end
else begin
ww(k,k+(n div 2)-1);
ww(k+(n div 2),k+n-1);
for i:=k to (n div 2)-1 do
for j:= k+(n div 2) to k+n-1 do
a[i,j]:=a[i+(n div 2),j-(n div 2)];
for i:=k+(n div 2) to k+n-1 do
for j:= k+(n div 2) to k+n-1 do
a[i,j]:=a[i-(n div 2),j-n div 2];
end;
end;
BEGIN
read(m);
ww(1,m);
for i1:=1 to m do
begin
for i2:=1 to m do
write(a[i1,i2],' ');
writeln;
end;
END.
帮帮忙,我怎么也过不了
參考答案:ww(k,k+(n div 2)-1);
ww(k+(n div 2),k+n-1);
应该成:
ww(k,n div 2);
ww(k+(n div 2),n div 2);
呵呵,赛程问题吧