bool search(int value, int values[], int n)
{
//проверим количество элементов в массиве
if (n <= 0)
return false;
//Находим "середину массива"
int middle=n/2;
if (value > values[middle])
return search(value, &values[middle + 1], n - middle - 1);
else if (value < values[middle])
return search(value, values, middle);
return true;
}
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
int main()
{
std::string str1 = "just string with some numbers 124632";
std::string str2 = "1234567890 i";
std::set<std::string::value_type> setOfSymbolsInStr1(
str1.begin(),
str1.end());
std::set<std::string::value_type> setOfSymbolsInStr2(
str2.begin(),
str2.end());
std::set<std::string::value_type> intersection;
std::set_intersection(
setOfSymbolsInStr1.begin(),
setOfSymbolsInStr1.end(),
setOfSymbolsInStr2.begin(),
setOfSymbolsInStr2.end(),
std::inserter(intersection, intersection.begin()));
std::cout << intersection.size() << std::endl;
return 0;
}