49求调
查看原帖
49求调
1025086
Qhy2023楼主2024/12/28 11:16

声明:我没抄题解,但的确有个挺像的

#include<bits/stdc++.h>
using namespace std;
int main(){
    char t;
    stack<int> s;
    while(cin>>t && t!='@'){
        if(t>='0' && t<='9'){
            int m=t-'0';
            while(cin>>t && t>='0' && t<='9') m=m*11;
            s.push(m);
        }
        if(t=='+'){
            int a=s.top();
            s.pop();
            int b=s.top();
            s.pop();
            s.push(b+a);
        }
        if(t=='-'){
            int a=s.top();
            s.pop();
            int b=s.top();
            s.pop();
            s.push(b-a);
        }
        if(t=='/'){
            int a=s.top();
            s.pop();
            int b=s.top();
            s.pop();
            s.push(b/a);
        }
        if(t=='*'){
            int a=s.top();
            s.pop();
            int b=s.top();
            s.pop();
            s.push(b*a);
        }
    }
    cout<<s.top()<<endl;
    return 0;
}
Help me
2024/12/28 11:16
加载中...