handless @ 2024-12-27 19:05:09
#include <iostream>
#include <string>
#include <stack>
#include <cctype>
using namespace std;
stack<char> st;
int main()
{
char ch;
while(cin >> ch)
{
if(ch=='@')
{
break;
}
if(isdigit(ch))
{
st.push(ch);
}
else if(ch=='+')
{
int n1=st.top();
st.pop();
int n2=st.top();
st.pop();
st.push(n2+n1);
}
else if(ch=='-')
{
int n1=st.top();
st.pop();
int n2=st.top();
st.pop();
st.push(n2-n1);
}
else if(ch=='*')
{
int n1=st.top();
st.pop();
int n2=st.top();
st.pop();
st.push(n2*n1);
}
else if(ch=='/')
{
int n1=st.top();
st.pop();
int n2=st.top();
st.pop();
st.push(n2/n1);
}
else
{
continue;
}
}
cout << st.top() << endl;
return 0;
}
by username____ @ 2024-12-27 19:07:41
交一下不就知道了吗
by lth3020 @ 2024-12-27 19:09:56
最后的输出是英文的么