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 |
WA了这么久,终于出来了(pascal)type tp = record x,y:integer; end; var cset: array[1..100, 1..100] of char; m, n, i, j, asc, asc2, sm, sn: integer; s, e: tp; procedure print; var i, j: integer; begin for i := 1 to sm do begin for j := 1 to sn do write(' ', cset[i, j]); writeln; end; end; function isFull:boolean; var i, j: integer; begin isFull := True; for i := 1 to sm do for j := 1 to sn do if cset[i,j] = ' ' then isFull := false; end; procedure check(var i: integer); begin if i + 1>90 then i := 64; end; begin readln(m, n); sm := m; sn := n; asc := 64; s.x := 1; s.y := 1; e.x := m; e.y := n; fillchar(cset, sizeof(cset), ' '); while (m>0) and (n>0) do begin for i := s.y to e.y do begin check(asc); inc(asc); if isFull then break; cset[s.x, i] := chr(asc); end; asc2 := asc + m - 2; for i := e.y downto s.y+1 do begin check(asc2); inc(asc2); if isFull then break; cset[e.x, i] := chr(asc2); end; for i := s.x+1 to e.x do begin check(asc); inc(asc); if isFull then break; cset[i, e.y] := chr(asc); end; for i := e.x downto s.x+1 do begin check(asc2); inc(asc2); if isFull then break; cset[i, s.y] := chr(asc2); end; asc := asc2; dec(m, 2); dec(n, 2); inc(s.x); inc(s.y); dec(e.x); dec(e.y); end; print; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator