- 数字反转
- 2016-08-23 16:17:44 @
var
s:string;
a:array[0..12]of longint;
i,j,l:longint;
begin
readln(s);
l:=length(s);
if s[1]='-'
then
begin
write('-');
for i:=l downto 2 do
if s[i]<>'0' then break;
for j:=i downto 2 do
write(s[j]);
end
else
begin
for i:=l downto 1 do
if s[i]<>'0' then break;
for j:=i downto 1 do
write(s[j]);
end;
writeln;
end.
1 条评论
-
hahayang LV 10 @ 2017-02-05 15:53:23
var s:string; i:longint; begin read(s); for i:=length(s) downto 1 do if s[i]='0' then delete(s, i, 1) else break; if s=''then s:='0'; if s[1]='-' then begin write(s[1]); for i:=length(s) downto 2 do write(s[i]) end else for i:=length(s) downto 1 do write(s[i]) end.
- 1