#include <string>
#include <algorithm>
#include <functional>
#include <iostream>
#include <ctype.h>
/*
Написать функцию, которая получает в качестве параметров две строки
и возвращает в вызывающую программу количество прописных букв,
одновременно содержащихся в заданных строках.
*/
template <typename T>
struct is_capital : public std::unary_function<typename T::value_type, bool>
{
bool operator()(typename T::value_type v) const
{
return !!isupper(v);
}
};
std::string f(const std::string& s)
{
std::string tmp;
std::remove_copy_if(s.begin(), s.end(), std::back_inserter(tmp), std::not1(is_capital<std::string>()));
std::sort(tmp.begin(), tmp.end());
tmp.erase(std::unique(tmp.begin(), tmp.end()), tmp.end());
return tmp;
}
size_t num(const std::string& s1, const std::string& s2)
{
const std::string tmp1 = f(s1);
const std::string tmp2 = f(s2);
std::string res;
std::set_intersection(tmp1.begin(), tmp1.end(), tmp2.begin(), tmp2.end(), std::back_inserter(res));
return res.size();
}
int main()
{
std::cout << num("HELLO", "WORLD") << std::endl;
std::cout << num("Hello", "World") << std::endl;
return 0;
}