Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

28行超简短pascal代码,1遍水过

Posted by 740340735 at 2011-08-29 12:47:18 on Problem 3752
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator