【Luogu1449】后缀表达式
problem
solution
codes
#include<iostream>
#include<stack>
using namespace std;
stack<int>s;
int main(){
char ch; int t=0;
while(cin>>ch && ch!='@'){
if(ch>='0'&&ch<='9')t=t*10+ch-'0';
else if(ch=='.'){
s.push(t); t = 0;
}else{
int a = s.top(); s.pop();
int b = s.top(); s.pop();
if(ch=='+')s.push(b+a);
else if(ch=='-')s.push(b-a);
else if(ch=='*')s.push(b*a);
else if(ch=='/')s.push(b/a);
}
}
cout<<s.top()<<"\n";
return 0;
}