1AC 2WA 2RE 求调

P1449 后缀表达式

_Jimmy01 @ 2023-11-09 21:18:18

#include <bits/stdc++.h>
using namespace std;
int main(){
    stack<int>a;
    while(1+1==2){
        char n;
        int x,y;
        n=getchar();
        if(n=='.') continue;
        if(n=='@') break;
        if(n>='0'&&n<='9') a.push((int)(n-'0'));
        else{
            y=a.top();a.pop();x=a.top();a.pop();
            if(n=='-') a.push(x-y);
            if(n=='+') a.push(x+y);
            if(n=='*') a.push(x*y);
            if(n=='/') a.push(x/y);
            cout<<a.top();
        }
    }
    cout<<a.top();
    return 0;
}

感谢dalao们qwq


by SzYuan @ 2023-11-16 16:07:19

数字不一定是个位数


by spindrift @ 2023-11-20 18:45:20

哈哈哈 我跟你的情况一样


|