样例没过,求助
查看原帖
样例没过,求助
804115
yzm0325楼主2023/8/11 14:58
#include <bits/stdc++.h>
using namespace std;
stack <int> s;
int cnt;
char c;
int main() {
    while((c = getchar()) != '@') {
        if(c >= '0' && c <= '9') cnt = cnt * 10 + c - '0';
        else if(c == '.') s.push(cnt), cnt = 0;
        else {
            int x = s.top(); s.pop();
            int y = s.top(); s.pop();
            switch(c) {
                case '+': s.push(x + y); break;
                case '-': s.push(x - y); break;
                case '*': s.push(x * y); break;
                case '/': s.push(y / x); break;
            }
        }
    }
    cout << s.top();
    return 0;
}
2023/8/11 14:58
加载中...