问题标题: 酷丁编程:11498 逆波兰表达式2

0
0
已解决
胡子靖
胡子靖
初级守护
初级守护

题目链接: 酷丁编程:11498

#include<bits/stdc++.h>
using namespace std;
stack<int> s;
string a;
int n,m;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        if(a=="+"){
            int x=s.top();
            s.pop();
            x=s.top()+x;
            s.pop();
            s.push(x);
        }else if(a=="*"){
            int x=s.top();
            s.pop();
            x=s.top()*x;
            s.pop();
            s.push(x);
        }else{
            stringstream ss;
            ss<<a;
            ss>>m;
            s.push(m);
        }
    }
    printf("%d",s.top());
    return 0;
}

10分Wa


0
已采纳
范聿舟
范聿舟
初级光能
初级光能

题目说要取模%

我要回答