fix(cpp). update hash_map (#800)

* fix(cpp). update hash_map

遍历 map 还是 k-v 键值对

* Update hash_map.md

---------

Co-authored-by: Yudong Jin <krahets@163.com>
pull/803/head
Flamingo 1 year ago committed by GitHub
parent ea7eb514fc
commit 22be495412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -39,13 +39,13 @@ int main() {
} }
cout << "\n单独遍历键 Key" << endl; cout << "\n单独遍历键 Key" << endl;
for (auto key : map) { for (auto kv : map) {
cout << key.first << endl; cout << kv.first << endl;
} }
cout << "\n单独遍历值 Value" << endl; cout << "\n单独遍历值 Value" << endl;
for (auto val : map) { for (auto kv : map) {
cout << val.second << endl; cout << kv.second << endl;
} }
return 0; return 0;

@ -299,12 +299,12 @@
cout << kv.first << " -> " << kv.second << endl; cout << kv.first << " -> " << kv.second << endl;
} }
// 单独遍历键 key // 单独遍历键 key
for (auto key: map) { for (auto kv: map) {
cout << key.first << endl; cout << kv.first << endl;
} }
// 单独遍历值 value // 单独遍历值 value
for (auto val: map) { for (auto kv: map) {
cout << val.second << endl; cout << kv.second << endl;
} }
``` ```

Loading…
Cancel
Save