| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
28行超简短pascal代码,1遍水过const dx:array[0..3] of longint=(0,1,0,-1);
dy:array[0..3] of longint=(1,0,-1,0);
var n,m,x,y,d,i,j:longint;
a:array[0..100,0..100] of longint;
b:array[0..100,0..100] of boolean;
begin
readln(n,m);
x:=1;y:=1;d:=0;
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),false);
for i:=1 to n do
for j:=1 to m do
b[i,j]:=true;
a[1,1]:=0;i:=0;b[1,1]:=false;
while true do begin
i:=(i+1) mod 26;
if not b[x+dx[d],y+dy[d]] then d:=(d+1) mod 4;
inc(x,dx[d]);inc(y,dy[d]);
if not b[x,y] then break;
b[x,y]:=false;a[x,y]:=i;
end;
for i:=1 to n do begin
for j:=1 to m do
write(' ',chr(ord('A')+a[i,j]));
writeln;
end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator