c++ 在指定长度的数组或者容器中,统计元素出现的次数(count)

#include <iostream>     // cout
#include <algorithm> // count
#include <vector> // vector
using namespace std;
int main () {
// counting elements in array:
int myints[] = {,,,,,,,}; // 8 elements
int mycount = count(myints, myints+, );
cout << "10 appears " << mycount << " times.\n"; // counting elements in container:
vector<int> myvector (myints, myints+);
mycount = count(myvector.begin()+, myvector.end(), );
cout << "20 appears " << mycount << " times.\n"; return ;
}
上一篇:Dynamic Inversions II 逆序数的性质 树状数组求逆序数


下一篇:hdu 1394 Minimum Inversion Number(逆序数对) : 树状数组 O(nlogn)