C++ STL Map需要有两个Key该咋办? 發表於 2020-10-11 | 分類於 C++ , STL | 字數統計: 135 | 閱讀時長 ≈ 1 施工中…… 使用pair112345678//非完全代码,此方法编译通过typedef pair<int,int> pairInt; //定义两个keytypedef map<pairInt,int> mapInt; //定义mapvector<mapInt> uv(line); //实现类似二维数组uv[i].insert(make_pair(pairInt(a,b),c)); //插入uv[i].count(make_pair(from[i][j],to[i][m])); //查询keyint temp = uv[i].at(make_pair(from[i][j],to[i][m])); //取值 奇技淫巧你甚至可以把两个Key连起来,变成一个String🤦 参考资料: STL之map两个key LeetCode 报错解决 heap-buffer-overflow Heap-use-after-free Stack-buffer-overflow Global-buffer-overflow Post author: Kronos Post link: https://sakronos.github.io/Note/2020/10/11/C-STL有两个Key该咋办?/ Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.