qiu zhu, 49 fen!
查看原帖
qiu zhu, 49 fen!
532067
rochcim楼主2021/9/10 19:02
#include <iostream>
#include <stack>
#include <cstdio>
using namespace std;
stack < char > p;
int main () {
    char ch;
    int s = 0;
    do {
        ch = getchar();
        if (ch >= '0' && ch <= '9') 
            s = s * 10 + ch - '0';
        else if (ch == '.'){
            p.push(s);
            s = 0;
        }
        else if (ch != '@'){
            int x = p.top(); p.pop();
            int y = p.top(); p.pop();
            switch (ch) {
                case '+': p.push(x + y); break;
                case '-': p.push(y - x); break;
                case '*': p.push(x * y); break;
                case '/': p.push(y / x); break;
            }
        }
    } while (ch != '@');
    printf("%d\n", p.top());
    return 0;
}
49 fen, qiu zhu, xie xie!
2021/9/10 19:02
加载中...