求调!!!

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

```cpp #include <bits/stdc++.h> ``` using namespace std; char s[1000]; char x; double zhi = 0; int deng = 1, tot, xi, fu = 1; int main() { cin>>s; int y; y=strlen(s); for (int i = 0; i < y; i++) { if (s[i] == '-') { zhi -= tot * deng * fu; tot = 0; fu = -1; } else if (s[i] == '+') { zhi -= tot * deng * fu; tot = 0; fu = 1; } else if (s[i] == '=') { zhi -= tot * deng * fu; deng = -1; tot = 0; fu = 1; } else if (s[i] >= 'a' && s[i] <= 'z') { xi = xi + tot * deng * fu; if (xi == 0) xi = 1; x = s[i]; tot = 0; } else tot = tot * 10 + (s[i] - '0'); } zhi += tot * fu; printf("%c=%.3lf\n", x, zhi / xi); return 0; }
by Menasor @ 2023-07-24 14:42:33


|