当前位置:首页|资讯

c++

作者:小峰boy发布时间:2024-10-13

#include <bits/stdc++.h>

using namespace std;

int main(){

    stack <int> s;

    int a, b, number = 0, sum = 0;

    char c;

    while (c != '@'){

        c = getchar();

        if (c == '0'){

            s.push(number)

            number = 0;

            continue;

        } if (c >= '0' && c <= '9') number = number * 10 + (c - '0');

        else {

            a = s.top(); s.pop();

            b = s.top(); s.pop();

            if (c == '+') s.push(a + b);

            else if (c == '-') s.push(a - b);

            else if (c == '*') s.push(a * b);

            else if (c == '/') s.push(b / a); }}

cout << s.top();

return 0;

}

2021年12月4日放在了草稿箱,翻的时候发现的

导致现在才投稿

猜猜我在写什么?


Copyright © 2024 aigcdaily.cn  北京智识时代科技有限公司  版权所有  京ICP备2023006237号-1