Pascal:求大神指教,为什么只有80分?

P1307 [NOIP2011 普及组] 数字反转

浅笑安然 @ 2017-08-15 11:54:05

var
        n,x,s:longint;
begin
        readln(n);
        x:=abs(n);
        if n<0 then write('-');
        s:=x mod 10;
        if s<>0 then write(s);
        x:=x div 10; 
        repeat
                s:=x mod 10;
                write(s);
                x:=x div 10;
        until x=0;
end.

by PY_Fighter @ 2017-08-18 12:09:20

100就炸了


by 钟诺成 @ 2017-08-25 13:34:05

如果末尾有两个0,你就只删了一个


by Komes @ 2017-08-26 15:37:18

var
        n,x,s,j:longint;
begin
        readln(n);
        x:=abs(n);
        if n<0 then write('-');
        s:=x mod 10;
        j:=1; 
        if s<>0 then
        begin
                inc(j);
                write(s);
        end;
        x:=x div 10; 
        repeat
                s:=x mod 10;
                if ((s=0) and (j<>1)) or (s<>0) then
                begin
                        inc(j);
                        write(s);
                end;
                x:=x div 10;
        until x=0;
end.
修正后的代码

by 风兮 @ 2017-09-21 17:35:27

有毒


|