为什么错误216

P1307 [NOIP2011 普及组] 数字反转

ws_fuweidong @ 2015-08-11 19:32:31

var
  i,j:longint;
  a:char;
  n:string;
begin
  read(n);
  i:=1;
  j:=length(n);
  if n[1]<>'-' then
  begin
  while i<>j do
  begin
    a:=n[i];
    n[i]:=n[j];
    n[j]:=a;
    inc(i);
    dec(j);
  end;
  end;
   if n[1]='-' then
  begin
  i:=2;
  while i<>j do
  begin
    a:=n[i];
    n[i]:=n[j];
    n[j]:=a;
    inc(i);
    dec(j);
  end;
  end;
  for i:=1 to length(n) do
  begin
  if n[i]='-' then continue;
  while n[i]='0' do
  delete(n,i,1);
  end;
  writeln(n);
end.

|