34 lines
592 B
C++
34 lines
592 B
C++
#include<bits/stdc++.h>
|
|
using namespace std;
|
|
typedef long long ll;
|
|
|
|
stack<ll> s;
|
|
|
|
int main(){
|
|
int i;
|
|
cin>>i;
|
|
char f;
|
|
s.push(i);
|
|
while(cin>>f){
|
|
cin>>i;
|
|
if(f=='+'){
|
|
s.push(i);
|
|
}else if(f=='-'){
|
|
s.push(-i);
|
|
}else if(f=='*'){
|
|
int h = s.top();
|
|
s.pop();
|
|
s.push(h*i);
|
|
}else{
|
|
int h = s.top();
|
|
s.pop();
|
|
s.push(h/i);
|
|
}
|
|
}
|
|
int ans = 0;
|
|
while(s.empty()==false){
|
|
ans+=s.top();
|
|
s.pop();
|
|
}
|
|
cout<<ans<<endl;
|
|
} |