#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;
}
#include <iostream>
void printArray(const int * array, size_t len)
{
std::cout << "[ ";
for(size_t i = 0; i < len; ++i)
std::cout << array[i] << (i == len - 1 ? "" : ", ");
std::cout << " ]" << std::endl;
}
void _reverseArray(int * first, int *last)
{
int tmp = *first;
*first = *last;
*last = tmp;
if(first < last)
_reverseArray(first + 1, last - 1);
}
void reverseArray(int * ptr, size_t len)
{
_reverseArray(ptr, ptr + len - 1);
}
int main() {
int array[] = { 1, 2, 3, 4, 5, 6 };
size_t len = sizeof(array) / sizeof(int);
printArray(array, len);
reverseArray(array, len);
printArray(array, len);
return 0;
}