题解

P1307 [NOIP2011 普及组] 数字反转

我爱编程 @ 2017-04-24 12:59:40

var
s:string;
c:char;
i,j,len1,len2: integer;
begin
len1:=0;
readln(s);
    if (s='0') then begin writeln(s); exit; end; //处理s='0'的情况
len2:=length(s)+1;
repeat
dec(len2); //把数字最后的0去掉
until (s[len2]<>'0')or(len2>length(s));
    if s[1]='-' then begin write('-'); inc(len1); end; //处理负数
for i:=len2 downto len1+1 do
write(s[i]);
readln;
end.

by 我爱编程 @ 2017-04-24 13:00:27

还有问一句为什么会出现“词条被锁定”


|