docs(cpp): 补全 ch02 range-for 练习参考答案 - #179
Merged
Charliechen114514 merged 2 commits intoAug 30, 2026
Merged
Conversation
Charliechen114514
requested changes
Aug 30, 2026
Charliechen114514
merged commit Aug 30, 2026
f10e714
into
Awesome-Embedded-Learning-Studio:main
4 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
补全《range-for 循环》章节中三个练习的参考答案,帮助初学者在完成练习后进行自查,同时保持答案默认折叠,不影响主线阅读。
背景
原章节只有练习要求和预期输出,没有提供实现参考。学习者遇到问题时缺少可对照的完整代码,也无法确认自己的 range-for、引用和字符串处理方式是否正确。
具体改动
std::array<int, 8>和const auto&查找最大值。std::string,统计不区分大小写的元音字母数量。auto&原地修改数组,将负数转换为绝对值,并使用只读引用打印结果。g++ -std=c++17 -Wall -Wextra编译命令;验证
56、元音数量5、负数绝对值转换结果。markdownlint-cli2检查通过,0 issues。pnpm build完整构建通过,38 个分卷任务成功,生成 4550 个文件。trailing-whitespacepre-commit hook。影响范围
仅修改:
documents/vol1-fundamentals/ch02/03-range-for.md不涉及导航、代码目录、配置文件或其他章节。