字典初始化

数组和集合 / 字典

#include <iostream>
#include <map>
using namespace std;

//空字典
map<int, string>  d1;

//用一些数据初始化
map<int, string>  d2 = {
    {1, "one"}, {2, "two"}
};

for (auto &[k, v] : d2) {
    cout << "{" << k << ", '" << v << "'}; ";
}