fork(2) download
  1. #include <iostream>
  2. #include <stack>
  3. using namespace std;
  4.  
  5. int main() {
  6. stack<int>st;
  7. char x;
  8. while(cin>>x){
  9. if(x>='0' and x<='9')
  10. st.push(x-'0');
  11. if(x=='+'){
  12. int a=st.top();
  13. st.pop();
  14. int b=st.top();
  15. st.pop();
  16. st.push(a+b);
  17. }
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5280KB
stdin
8 9 + 1 7 - *
stdout
Standard output is empty