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

WA了这么久,终于出来了(pascal)

Posted by Jimx at 2011-01-28 15:20:29 on Problem 3752
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:
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