如何std::count根据最里面向量的第二个值来计算向量向量?
我将向量声明为:
vector< vector<int> > distance(data.size(),vector<int>(3));
Run Code Online (Sandbox Code Playgroud)
你不能用std::count它。您可以使用std::count_if。
std::count_if(distance.begin(), distance.end(),
[](vector<int> const& v) { return v[1] == whatever; });
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1553 次 |
| 最近记录: |