From 22be495412115c33ff83fd18dd8ac4c0b1fada0e Mon Sep 17 00:00:00 2001 From: Flamingo <490493499@qq.com> Date: Tue, 26 Sep 2023 11:07:14 +0800 Subject: [PATCH] fix(cpp). update hash_map (#800) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(cpp). update hash_map 遍历 map 还是 k-v 键值对 * Update hash_map.md --------- Co-authored-by: Yudong Jin --- codes/cpp/chapter_hashing/hash_map.cpp | 8 ++++---- docs/chapter_hashing/hash_map.md | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/codes/cpp/chapter_hashing/hash_map.cpp b/codes/cpp/chapter_hashing/hash_map.cpp index 1f295ec7b..090c2eb10 100644 --- a/codes/cpp/chapter_hashing/hash_map.cpp +++ b/codes/cpp/chapter_hashing/hash_map.cpp @@ -39,13 +39,13 @@ int main() { } cout << "\n单独遍历键 Key" << endl; - for (auto key : map) { - cout << key.first << endl; + for (auto kv : map) { + cout << kv.first << endl; } cout << "\n单独遍历值 Value" << endl; - for (auto val : map) { - cout << val.second << endl; + for (auto kv : map) { + cout << kv.second << endl; } return 0; diff --git a/docs/chapter_hashing/hash_map.md b/docs/chapter_hashing/hash_map.md index 6d10503bd..63ee3e347 100755 --- a/docs/chapter_hashing/hash_map.md +++ b/docs/chapter_hashing/hash_map.md @@ -299,12 +299,12 @@ cout << kv.first << " -> " << kv.second << endl; } // 单独遍历键 key - for (auto key: map) { - cout << key.first << endl; + for (auto kv: map) { + cout << kv.first << endl; } // 单独遍历值 value - for (auto val: map) { - cout << val.second << endl; + for (auto kv: map) { + cout << kv.second << endl; } ```