#include <iostream>
#include <string>
#include <random>
#include <algorithm>
#include <iterator>
#include <functional>
usingnamespace std;
int main()
{
random_device seed;
mt19937 rnd(seed());
uniform_int_distribution<> dist('a', 'z');
string s;
generate_n(back_inserter(s), 100, bind(dist, rnd));
std::cout << "randomly-generated string:\n" << s << '\n';
auto p = adjacent_find(s.begin(), s.end());
if(p == s.end())
cout << "The string has no adjacent pairs\n";
else
cout << "The first adjacent pair is at position " << p - s.begin()
<< " and the repeated letter is " << *p << '\n';
}