求第四个测试数据

P1449 后缀表达式

和其正 @ 2017-04-02 10:19:55

求第四个测试数据

#include<cstdio>
#include<stack>
using namespace std;
stack<int>Stack;
int main()
{
    char ch;
    while((ch=getchar())!='@')
    {
        int num=0;
        while(ch<='9'&&ch>='0')
        {
            num=num*10+(ch-'0');
            ch=getchar();
        }
        if(ch=='.')    Stack.push(num);
        else
        {
        int top=Stack.top();Stack.pop();
        int top2=Stack.top();Stack.pop();
        switch(ch)
            {
            case '*':
                Stack.push(top*top2);
                break;
            case '/':
                Stack.push(top2/top);
            case'+':
                Stack.push(top+top2);
                break;
            case'-':
                Stack.push(top2-top);
                break;
            }
        }
    }
    printf("%d\n",Stack.top());
}

by CrTsIr400 @ 2020-06-26 10:14:08

盗墓


|