后悔了
#include<bits/stdc++.h>
using namespace std;
int num[1001];
int main()
{
stack<int>st;
stack<char>stc;
vector<int>ve;
int n;cin >> n ;
for(int i=1;i<=n;i++)
{
int x;
cin >> x ;
st.push(x);
}
for(int i=1;i<n;i++)
{
char c;
cin >>c;
stc.push(c);
}
for(int i=1;i<n;i++)
{
char c = stc.top();//取出栈顶元素
//删除栈顶元素
stc.pop();
int a,b;a = st.top();st.pop();
b=st.top();st.pop();
if(c=='/'&&a==0)
{
cout << "ERROR: " << b << "/0";
return 0;
}
else {
int temp ;
if(c=='+')
{
temp = b+a;
st.push(temp);
}
else if(c=='-')
{
temp=b-a;
st.push(temp);
}
else if(c=='*')
{
temp = b*a;
if(temp==0);
else st.push(temp);
}
else {
temp = b/a;
st.push(temp);
}
}
}
int ans = st.top();
cout << ans;
return 0;
}