正解

P1449 后缀表达式

a___ @ 2017-03-24 13:23:57

#include <iostream>
#include <vector>
using namespace std;
int main()
{
    vector<int> s;
    char c;
    int now=0,a,b;
    while (cin>>c,c!='@')
    {
        if (c>='0'&&c<='9') now=now*10+c-'0';
        else if (c=='.')
        {
            s.push_back(now);
            now=0;
        }
        else
        {
            b=s[s.size()-1];s.pop_back();
            a=s[s.size()-1];s.pop_back();
            switch (c)
            { 
                case '+':{s.push_back (a+b);break;}
                case '-':{s.push_back (a-b);break;}
                case '*':{s.push_back (a*b);break;}
                case '/':{s.push_back (a/b);break;}
            }
        }
    }
    cout<<s[0]<<endl;
    return 0;
}

by M_sea @ 2017-04-16 11:11:20

666


by return @ 2017-06-29 14:43:27

@ yhw的

去题解啊


by y_kx_b @ 2022-08-22 11:33:54

tlqtj 烤谷*2


|