我对c++环境有些陌生,我正在尝试将用java编写的代码转换为c++,我想问是否有人可以帮助我在c++中找到与java Collection.frequency相当的代码。我试图将代码转换为以下代码:
List<Integer> foundCount = new ArrayList<~>();
.... // some code goes here
...
int count3 = Collections.frequency(foundCount,38);我真的很感激你的帮助
发布于 2015-10-12 13:08:33
标准API提供了用于计数的std::count。
vector<int> v = {23 , 34 , 23 , 583 , 34 , 23};
cout << "23 appears " << count(v.begin() , v.end() , 23) << " times in v"
<< endl;https://stackoverflow.com/questions/33081864
复制相似问题