jiashuangqi_oh_no @ 2024-11-24 13:53:10
//P210
#include<iostream>
#include<stack>
using namespace std;
stack<int> sta;
int s=0,x=0,y=0;
int main(){
char a;
do{
a=getchar();
if(a<='9'&&a>='0'){
s=s*10+a-'0';
}
else if(a=='.'){
sta.push(s),s=0;
}
else if(a!='@'){
x=sta.top(),sta.pop(),y=sta.top(),sta.pop();
switch(a){
case '+': sta.push(x+y);break;
case '-': sta.push(x-y);break;
case '*': sta.push(x*y);break;
case '/': sta.push(x/y);break;
}
}
}while (a!='@');
cout<<sta.top();
return 0;
}
by cthulhufthagn @ 2024-11-24 14:01:56
x先放,y再放 ,所以栈顶的其实是y