Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uses crt;
- var n,i,j,s,canle:longint;
- a:array[1..1000,1..1000]of longint;
- function check:boolean;
- var i,j:longint;
- begin
- check:=false;
- for i:=1 to n do
- for j:=1 to n do
- if a[i,j]=0 then begin check:=true; break end
- end;
- function sochuso:longint;
- var d:longint;
- begin
- d:=0;
- while s<>0 do begin inc(d); s:=s div 10 end;
- sochuso:=d;
- end;
- procedure phai;
- begin inc(s); inc(j); a[i,j]:=s; end;
- procedure trai;
- begin inc(s); dec(j); a[i,j]:=s; end;
- procedure tren;
- begin inc(s); dec(i); a[i,j]:=s; end;
- procedure duoi;
- begin inc(s); inc(i); a[i,j]:=s; end;
- begin
- write('N='); readln(n);
- for i:=1 to n do
- for j:=1 to n do
- a[i,j]:=0;
- i:=1; j:=1; a[1,1]:=1; s:=1;
- while check do
- begin
- while (j+1<=n) and (a[i,j+1]=0) do phai;
- while (i+1<=n) and (a[i+1,j]=0) do duoi;
- while (j-1>=1) and (a[i,j-1]=0) do trai;
- while (i-1>=1) and (a[i-1,j]=0) do tren;
- end;
- canle:=sochuso+1;
- for i:=1 to n do
- begin writeln;
- for j:=1 to n do write(a[i,j]:canle);
- end;
- readln
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement