作业介绍

文档专区

静态数组 vs 动态数组(vector)

https://www.kdocs.cn/l/cfwmEF1zP3n8

二维vector 输入_输出方式汇总

https://www.kdocs.cn/l/cpqFkvNiprQa

栈

https://www.kdocs.cn/l/cabYLKck1KtM

栈的 stl 与数组模拟对照

https://www.kdocs.cn/l/chMknoYJeOY3

中缀、前缀、后缀表达式转换

https://www.kdocs.cn/l/cmcgF0KVZMSY

队列

https://www.kdocs.cn/l/cck39VMIIsWw

指针与链表

https://www.kdocs.cn/l/ceahM6NXKZKb

练习专区

CSP-J 初赛专项训练:栈、队列、链表

https://www.kdocs.cn/l/cqb7LSuAaqPz

答案https://www.kdocs.cn/l/cmvkAG8KJV6I

CSP-J 初赛真题精选:线性结构专项

https://www.kdocs.cn/l/canmtvVRPUD5

答案https://www.kdocs.cn/l/cmpiRuWvSi8F

CSP-J 初赛专项训练:指针与链表

https://www.kdocs.cn/l/cirQDoVLKT7v

答案https://www.kdocs.cn/l/cf5mv1sfksB0

表达式转换与求值专项练习题

https://www.kdocs.cn/l/ccQWdvkyzCWe

答案 https://www.kdocs.cn/l/cowdzh7LIFN2

队列安排数组模拟队列

队列安排结构体模拟队列

后缀表达式

#include <iostream>
#include <stack>
#include <string>
using namespace std;

int main()
{
    string s;
    cin >> s;
    stack<long long> st;
    long long num = ____;  // 提示:数字累加变量初始值

    for (char c : s)
    {
        if (c >= '0' && c <= '9')
        {
            num = ________________________;  // 提示:字符转数字,多位数拼接公式
        }
        else if (c == '.')
        {
            st.____(num);  // 提示:把解析完成的数字压入栈
            num = 0;
        }
        else if (c == '+' || c == '-' || c == '*' || c == '/')
        {
            long long b = st.top(); st.pop(); // b:先弹出,右操作数
            long long a = st.top(); st.pop(); // a:后弹出,左操作数
            long long res;
            if (c == '+') res = ________;   // 提示:a 加 b
            else if (c == '-') res = ________;  // 提示:a 减 b,注意顺序不能写反 b-a
            else if (c == '*') res = ________;  // 提示:a 乘 b
            else res = ________;  // 提示:a 除以 b,C++向0取整
            st.________;  // 提示:把运算结果压回栈中
        }
        else if (c == '@')
        {
            ________;  // 提示:读到结束符号,跳出for循环
        }
    }
    cout << st.top() << '\n';
    return 0;
}

状态
已结束
题目
9
开始时间
2026-8-4 0:00
截止时间
2026-9-30 23:59
可延期
24 小时