c++ - 如何在 vector<vector<pair<int,int>> 中插入一个 vpii >

标签 c++ vector stl

<分区>

如何在 vector< vector < pair < int,int > > > 中插入 vector 对?

我是STL的初学者所以请帮助我。

最佳答案

这是如何在 vector<vector<pair<int,int> > > 中插入 vpii :

vector<vector<pair< int,int> > > vvpii;
pair<int, int> pii(1, 2);
vector<pair<int, int> > vpii;
vpii.push_back(pii);
vvpii.push_back(vpii);

// or if your compiler supports c++11,
// you can use Brace-enclosed initializer lists
vvpii.push_back({ // vector initializer
    {1, 2}, // pair initializer
    {2, 3}, // another pair
});

关于c++ - 如何在 vector<vector<pair<int,int>> 中插入一个 vpii >,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22225013/

相关文章:

C++ 多值初始化

c++ - 让 constexpr 在 OSX 上的 C++17 中与 pow 一起使用

r - 在R中不使用NA强制将字符转换为数值

c++ - 如何廉价地将 C 样式数组分配给 std::vector?

c++ - 我使用相同的方法进行字符串连接,但第一个显示错误,第二个显示结果

c++ - 由于C++中的表导致编译错误

c++ - 相同的代码, vector 更改为 unordered_set 时出错

c++ - 交换时增量迭代器 std::next

c - 在哪里可以找到 C++ STL 映射的 C 实现?

c++ - vector<string>::iterator - 如何找到元素的位置