You can use std::find from <algorithm>: std::find(vector.begin(), vector.end(), item) != vector.end() This returns a bool (true if present, false otherwise). With your example: #include <algorithm> if ( std::find(vector.begin(), vector.end(),…
std::list::erase Erase elements Removes from the list container either a single element (position) or a range of elements ([first,last)).This effectively reduces the container size by the number of elements removed, which are destroyed.Unlike other s…
方法一: >>> mylist = [1,2,2,2,2,3,3,3,4,4,4,4] >>> myset = set(mylist) >>> for item in myset: print("the %d has found %d" %(item,mylist.count(item))) the 1 has found 1 the 2 has found 4 the 3 has found 3 the 4 has found 4…