全TLE求助
查看原帖
全TLE求助
1401899
aikepudelizhi楼主2024/8/7 22:22
#include<bits/stdc++.h>
using namespace std;
stack <int> s1;
int main(){
    char a;
    int b,x,y;
    while(a!='@'){
        b=((int)a)-48;
        if(a>='0'&&a<='9'){
            s1.push(b);
        }
        else if(a=='+'){
            x=s1.top();
            s1.pop();
            y=s1.top();
            s1.pop();
            s1.push(x+y);
        }
        else if(a=='-'){
            x=s1.top();
            s1.pop();
            y=s1.top();
            s1.pop();
            s1.push(x-y);
        }
        else if(a=='*'){
            x=s1.top();
            s1.pop();
            y=s1.top();
            s1.pop();
            s1.push(x*y);
        }
        else if(a=='/'){
            x=s1.top();
            s1.pop();
            y=s1.top();
            s1.pop();
            s1.push(x/y);
        }
    }
    cout<<s1.top();
    return 0;
}
2024/8/7 22:22
加载中...