请教大佬,本蒟蒻的代码错在哪里?
#include <bits/stdc++.h>
using namespace std;
string s;
char x;
double zhi = 0.0;
int deng = 1, tot, xi, fu = 1;
int main()
{
getline(cin, s);
for (int i = 0; i < s.size(); 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;
}