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 |
用pascal怎么做啊,老是超时,好要不要命啊!!顺便解决了~var n,i,j,k:longint; f:array[0..1000,0..1000] of char; procedure draw(x,y,n:longint); var k,i:longint; begin if n=1 then f[x,y]:='X' else begin k:=1; for i:=1 to (n-1) do k:=k*3; k:=k div 3; draw(x,y,n-1); draw(x,k*2+y,n-1); draw(k+x,k+y,n-1); draw(k*2+x,y,n-1); draw(k*2+x,k*2+y,n-1); end; end; begin while not eof do begin readln(n); fillchar(f,sizeof(f),' '); draw(1,1,n); k:=1; for i:=1 to (n-1) do k:=k*3; for i:=1 to k do begin for j:=1 to k do begin write(f[i,j]); end; writeln; end; 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