#include<bits/stdc++.h>

using namespace std;

int main(){
	stack<int> num;
	string s;
	
	while(cin>>s){
		int first =  num.top();	num.pop();
		int second = num.top(); num.pop();	
		if(s=='+'||s=='-'||s=='*'||s=='/'){
			if(s=="+") num.push(first+second);
			if(s==) num.push(first-second);
			if(s=='*') num.push(first*second);
			if(s=='/') num.push(first/second);
		} else {
			num.push(stoi(s));
		}
	}
	cout<<num.top()<<"\n";
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: