讨论 / [NOIP2000 计算器改良] 为什么我会有无效浮点操作?
sesame 2011-03-03 04:44:00
点我顶贴 收藏 删除
查看状态 Show Status

状态题目:[NOIP2000]计算器的改良

题目编号:344-[NOIP2000]计算器的改良 查看该题

状态: Unaccepted

测评机: Xeost[5]

得分: 80分

提交日期: 2009-8-18 23:25:00

有效耗时: 344毫秒

测试结果1: 通过本测试点|有效耗时172ms

测试结果2: 通过本测试点|有效耗时47ms

测试结果3: 通过本测试点|有效耗时63ms

测试结果4: 通过本测试点|有效耗时62ms

测试结果5: 运行错误|无效浮点操作

program NOIP2000_jisuanji;

{$E+}

var q,xx:char;

i,t,j,k,m,n,z,x,a,num,zimu:longint;

st:string;

ans:extended;

begin

while not eoln do

begin

read(q);

inc(t);

st:=st+q;

if q=’=’ then n:=t;

end;

for i:= 1 to n-1 do

begin

if st[i]=’-’ then

begin

case m of

0:inc(num,x);

1:dec(num,x);

end;

m:=1;

x:=0;

end;

if st[i]=’+’ then

begin

case m of

0:inc(num,x);

1:dec(num,x);

end;

m:=0;

x:=0;

end;

if ((st[i]>=’a’)and(st[i]<=’z’)) then

begin

q:=st[i];

if x=0 then inc(x);

case m of

1:dec(zimu,x);

0:inc(zimu,x);

end;

x:=0;

end;

if ((st[i]>=’0’)and(st[i]<=’9’)) then

begin

x:= x*10+ord(st[i])-ord(’0’);

end;

end;

case m of

1: dec(num,x);

0: inc(num,x);

end;

x:=0;

m:=0;

for i:= n+1 to t do

begin

if st[i]=’-’ then

begin

case m of

1:inc(num,x);

0:dec(num,x);

end;

m:=1;

x:=0;

end;

if st[i]=’+’ then

begin

case m of

1:inc(num,x);

0:dec(num,x);

end;

m:=0;

x:=0;

end;

if ((st[i]>=’a’)and(st[i]<=’z’)) then

begin

q:=st[i];

case m of

0:dec(zimu,x);

1:inc(zimu,x);

end;

x:=0;

end;

if ((st[i]>=’0’)and(st[i]<=’9’)) then

begin

x:= x*10+ord(st[i])-ord(’0’);

end;

end;

case m of

1 : inc(num,x);

0 : dec(num,x);

end;

ans:=(-num)/zimu;

writeln(q,’=’,ans:0:3);

end.

#1 yangchen@2011-03-03 04:44:00
回复 删除
在开始时加入E+

这样就可以使用extended等类型了

查看更多回复
提交回复