- 数字反转
- 2013-08-11 18:24:44 @
贴出丑陋超短代码供大家BS~~
var a:string;i,j:longint;
begin
readln(a);
if a[1]='-' then begin
write('-');
delete(a,1,1);
end;
i:=length(a);
while a[i]='0' do dec(i);
for j:=i downto 1 do write(a[j]);
end.
2 条评论
-
曹家好牛 LV 6 @ 2016-11-26 17:04:26
// input code here
-
2014-10-29 20:22:13@
var
a:string;
b:array[1..255]of integer;
c,i,s:integer;
begin
readln(a);
if a[1]='-' then
begin
write('-');
c:=2;
end
else c:=1;
s:=length(a);
for i:=c to s do
b[i]:=ord(a[i])-48;
i:=s;
while b[i]=0 do
begin
s:=s-1;
i:=i-1;
end;
for i:=s downto c do write(b[i]);
end.
- 1