题目:U117014
求救,哪位大神可以教教我!
#include <bits/stdc++.h>
using namespace std;
stack<int> s;
char a[10000];
int main()
{
int t = 0, sum = 0;
fgets(a, sizeof(a), stdin);
while (s.empty())
{
for (int i = 0; i <= strlen(a); i++)
{
s.push(a[i]);
if (a[i] == '+')
{
t = a[i - 1];
sum += s.top() + t;
s.pop();
}
else if (a[i] == '-')
{
t = a[i - 1];
sum += abs(s.top() - t);
s.pop();
}
else if (a[i] == '*')
{
t = a[i - 1];
sum += s.top() * t;
s.pop();
}
else if (a[i] == '/')
{
t = a[i - 1];
sum += abs(s.top() / t);
s.pop();
}
else t = a[i];
}
}
cout << sum << endl;
}