mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-16 11:02:09 +08:00
build
This commit is contained in:
@@ -308,13 +308,9 @@ comments: true
|
||||
for (auto kv: map) {
|
||||
cout << kv.first << " -> " << kv.second << endl;
|
||||
}
|
||||
// 单独遍历键 key
|
||||
for (auto kv: map) {
|
||||
cout << kv.first << endl;
|
||||
}
|
||||
// 单独遍历值 value
|
||||
for (auto kv: map) {
|
||||
cout << kv.second << endl;
|
||||
// 使用迭代器遍历 key->value
|
||||
for (auto iter = map.begin(); iter != map.end(); iter++) {
|
||||
cout << iter->first << "->" << iter->second << endl;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user