, , , , , . , , , .
, , , . Offhand, - :
int myfunc(set<string> in, string search){
assert(search.length() <= 32);
int result = 0;
for(set<string>::iterator iIn = in.begin(); iIn != in.end(); ++iIn)
{
bool isSubset = true;
if (iIn->length() != search.length())
isSubset = false;
for (int iSearch = 0; isSubset && iSearch < search.length; ++iSearch)
if (search[iSearch] == '1' && (*iIn)[iSearch] == '0')
isSubset = false;
if (isSubset)
++result;
}
return result;
}
:
int myfunc(set<string> in, string search){
int result = 0;
long searchInteger = strtol(search.c_str(), NULL, 2);
for(set<string>::iterator iIn = in.begin(); iIn != in.end(); ++iIn)
if ((strtol(iIn->c_str(), NULL, 2) & searchInteger) == searchInteger)
++result;
return result;
}