不用字符串用数组做错误在哪?求大神指点

P1307 [NOIP2011 普及组] 数字反转

小丑 @ 2015-08-26 16:03:08

program shuzifanzhuan;
var i,n,m,k:longint;
    a,b,c:array[0..100]of longint;
begin
 readln(n);
 k:=0;
 m:=0;
 b[1]:=n;
 c[1]:=1;
  begin
  for i:=1 to 100 do
  begin
  while c[i]<=b[1] do
  a[i]:=b[i] mod 10;
  b[i+1]:=b[i] div 10;
  c[i+1]:=10*c[i];
  k:=k+1;
  end;end;
 for i:=1 to k do
   begin
   if a[i]<>0 then m:=a[i]*c[k-i+1]+m;
   if (a[i]=0) and (i=k) then writeln(a[k]);halt;
   end;
writeln(m);
end.

|