mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-24 21:46:28 +08:00
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>
This commit is contained in:
parent
ea7eb514fc
commit
22be495412
2 changed files with 8 additions and 8 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue