求救,为什么输出 inf!

P1022 [NOIP2000 普及组] 计算器的改良

```cpp #include<bits/stdc++.h> using namespace std; int main() { int l,r; char x; char c; int f1=1,f2=1,tmp=0; while(scanf("%c",&c)!=EOF) { if(c>='0'&&c<='9') { tmp*=10; tmp+=c-'0'; } else { if (c>='a'&&c<='z') { if(tmp==0) l+=f2*f1; else l+=tmp*f2*f1; x=c; } else r+=tmp*(-f2)*f1; tmp=0; } if (c=='+') { f1=1; continue; } else if(c=='-') { f1=-1; continue; } else if(c=='=') { f2=-1,f1=1; continue; } } if(tmp!=0) r+=tmp*(-f2)*f1; printf("%c=%0.3f",x,1.0*r/l==0?abs(1.0*r/l):1.0*r/l); return 0; } ``` # 这样AC题
by linjunzhuo @ 2019-11-15 23:33:45


看不懂。。。
by Tune_ @ 2019-11-30 22:08:08


|