轻松的编程学习
首页
题库
学习路径
在线商城
能力地图
下载应用
登录 / 注册
菜单
⚠️ 管不了就原样递上去
👁️ 2 人浏览
💬 0 人评论
❤️ 添加收藏
(本条路线统一用
g++ -std=c++17 -O0 -Wall
编译)最上层要能接住,而且要拿到原来那句话。
提交你的答案
请登录后提交答案。
去登录
← 🔴 把 catch 的顺序排对
🔴 拥有和只看,怎么区分 →
更多题目
改成"你好,有词"
输出"100 分"
把年龄改成 20
输出学习天数 30
修复:给文字加引号
修复:补上右括号
代码编辑器
语言:
python3
c11
cpp17
Ctrl
+
Enter
运行
👩🏫 AI
▶ 运行代码
重置代码
打印代码
#include <iostream> #include <stdexcept> #include <string> static std::string path; static void mark(const char *n) { if (!path.empty()) path += ">"; path += n; } static int middle(int v) { mark("middle"); try { if (v < 0) throw std::invalid_argument("neg"); return v; } catch (const std::exception &) { mark("caught"); /* TODO: 这一层管不了,原样往上抛(别换类型、别吞掉)*/ return -1; } } int main() { int ok = middle(5); int top_caught = 0; std::string msg = "?"; try { middle(-1); } catch (const std::invalid_argument &e) { top_caught = 1; msg = e.what(); } std::cout << ok << "/" << top_caught << "/" << msg << "/" << path << "\n"; return 0; }
本次输入:
输出:
👩🏫
AI
请登录后使用 AI 老师
×
登录后可获得解题思路、提示与错误分析。
去登录
关闭
🎉
恭喜你,回答正确!
系统判定:正确
我知道了
💬 题目评论
提交
全部评论
全部评论