why?求dalao

P1307 [NOIP2011 普及组] 数字反转

天道酬勤 @ 2017-05-30 14:41:54

program p1307;
var 
 i,j,k,n,l:longint;
 s,t:string;
begin
readln(s);
l:=length(s);
if s[1]='-' then 
 begin 
  k:=-1;  
  for i:=2 to l do  
   begin  
    t[l-i+1]:=s[i];
    if s[i]='0' then n:=n+1;
    if n=l-1 then 
     begin
      writeln('0');
      exit;
     end;
   end;
 end
else
 begin 
  k:=1;  
  for i:=1 to l do  
   begin  
    t[l-i+1]:=s[i];
    if s[i]='0' then n:=n+1;
    if n=l then 
     begin
      writeln('0');
      exit;
     end;
   end;
 end;
i:=1;
while t[i]='0' do
 begin
  i:=i+1;
 end;
if k=-1 then
 begin
  writeln('-',t[i]);
 end
else
 writeln(t[i]);
for j:=i+1 to l do
 write(t[j]);
end.
略长了~\(≧▽≦)/~

|