This commit is contained in:
krahets
2023-10-25 00:05:05 +08:00
parent aae934ba24
commit f442443773
4 changed files with 318 additions and 152 deletions

View File

@@ -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;
}
```