讨论 / 没用高精度的程序
peterjiang 2011-08-26 09:35:00
点我顶贴 收藏 删除
以下仅供参考

program ss;

var

a,b:qword;

s,c:string;

i,j,k,x,y,z:integer;

begin

readln(c);

x:=0; y:=0;

if c[1]=- then begin x:=1; delete(c,1,1); end;

i:=1; a:=0;

while c[i] in [0..9] do

begin

a:=a*10+ord(c[i])-ord(0);

inc(i);

end;

delete(c,1,i);

if c[1]=- then begin y:=1; delete(c,1,1); end;

i:=1; b:=0;

while (i<=length(c))and(c[i] in [0..9]) do

begin

b:=b*10+ord(c[i])-ord(0);

inc(i);

end;

s:=;

i:=0;

j:=0;

if x=y then

begin

if a>b then begin z:=x; a:=a-b; end;

if a=b then begin z:=0; a:=0; end;

if a<b then begin z:=1-x; a:=b-a; end;

end

else

begin

z:=x; a:=a+b;

end;

if a=0 then s:=0;

while a>0 do

begin

k:=a mod 10;

s:=chr(ord(0)+k)+s;

inc(i);

if i mod 3=0 then s:=,+s;

a:=a div 10;

end;

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

if z=1 then s:=-+s;

write(s);

end.

#1 jesse@2011-08-26 09:35:00
回复 删除
s:=-+s?

s:=-+s 什么意思?

查看更多回复
提交回复