讨论 / 数字反转pascal
qazwsx123 2014-09-06 05:05:10
点我顶贴 收藏 删除
var s:string;

v,flag:int64;

c,i,len:longint;

begin

read(s);

val(s,v,c);

if (v=0) then write(0) else

if ((v<0) and (s[length(s)]='0')) then delete(s,length(s),1) else

if ((v>0) and (s[length(s)]='0')) then delete(s,length(s),1);

len:=length(s)+1;

repeat

if s[len]='0' then delete(s,len,1);

dec(len);

until s[len]<>'0';

if (v<0) then

begin

delete(s,1,1);

flag:=1;

end;

if flag=1 then write('-');

for i:=length(s) downto 1 do

write(s[i]);

end.

我是雷锋,不用谢!

#1 NEW WORLD@2014-09-26 06:59:44
回复 删除
评测详情

评测ID: 743804

用户名: [email protected]

状态: 测试通过 Accepted

得分 : 100

总时间耗费: 10ms

总内存耗费: 256B

运行结果

测试点#1.in 结果:AC 内存使用量: 256kB 时间使用量: 1ms

测试点#2.in 结果:AC 内存使用量: 256kB 时间使用量: 1ms

测试点#3.in 结果:AC 内存使用量: 256kB 时间使用量: 1ms

测试点#4.in 结果:AC 内存使用量: 256kB 时间使用量: 1ms

测试点#5.in 结果:AC 内存使用量: 256kB 时间使用量: 1ms

测试点#6.in 结果:AC 内存使用量: 256kB 时间使用量: 1ms

测试点#7.in 结果:AC 内存使用量: 256kB 时间使用量: 1ms

测试点#8.in 结果:AC 内存使用量: 256kB 时间使用量: 1ms

测试点#9.in 结果:AC 内存使用量: 256kB 时间使用量: 1ms

测试点#10.in 结果:AC 内存使用量: 256kB 时间使用量: 1ms

#2 lzsyxxyjl@2015-10-31 17:36:13
回复 删除
program c1130;

var f:boolean;

n:string;

i:integer;

begin

readln(n);

f:=true;

if n[1]='-' then

begin

write('-');

for i:=length(n) downto 2 do

begin

if (n[i]<>'0') then f:=false;

if f=false then write(n[i]);

end;

end

else

for i:=length(n) downto 1 do

begin

if (n[i]<>'0') then f:=false;

if f=false then write(n[i]);

end;

if f=true then write('0');

readln;

readln;

end.

查看更多回复
提交回复