讨论 / 为什么最后一个点WA了
Fish、のTorres 2011-07-12 06:00:00
点我顶贴 收藏 删除
var x,u,s,z:string;

r,f,a,b,c,d,l,t,i,j,k:longint;

begin

readln(s);

l:=length(s);

for i:=1 to l do

if s[i]='=' then t:=i;

f:=1;

for i:=1 to t-1 do begin

if (ord(s[i])>=48) and (ord(s[i])<=57) then u:=u+s[i];

if (ord(s[i])>=65) and (ord(s[i])<=122) then x:=x+s[i];

if (u<>'') and ((s[i]='-') or (s[i]='+') or (i=t-1)) then begin

if x<>'' then begin

z:=x;

val(u,r);

a:=a+f*r;

x:='';

u:='';

end

else begin

val(u,r);

c:=c+f*r;

u:='';

end;

f:=1;

end;

if s[i]='-' then f:=-1;

end;

f:=1;

for i:=t+1 to l do begin

if (ord(s[i])>=48) and (ord(s[i])<=57) then u:=u+s[i];

if (ord(s[i])>=65) and (ord(s[i])<=122) then x:=x+s[i];

if (u<>'') and ((s[i]='-') or (s[i]='+') or (i=l)) then begin

if x<>'' then begin

z:=x;

val(u,r);

b:=b+f*r;

x:='';

u:='';

end

else begin

val(u,r);

d:=d+f*r;

u:='';

end;

f:=1;

end;

if s[i]='-' then f:=-1;

end;

writeln(z,'=',(d-c)/(a-b):0:3);

// writeln(a,' ',b,' ',c,' ',d);

end.

#1 热心人士@2011-07-12 06:00:00
回复 删除
- -负数……

-0.0001只保留三个小数点的话就变成-0.000了,应该显示为0.000

查看更多回复
提交回复