Загадка Жака Фреско
#include<iostream>
#include<set>
#include<string>
using namespace std;
string generate()
{
unsigned n = rand() % 10 + 5; string t;
for (int j = 0; j < n; j++)
{
t += rand() % 25 + 97;
}
return t;
}
int main()
{
set<string> reptiloid; srand(unsigned(time(0)));
unsigned N = 10, f = rand()%10;
for (auto c = 0; c < N; c++)
{
reptiloid.insert(generate());
}
for (const auto& s : reptiloid)
{
cout << s << endl;
}
unsigned g = 0;
for (set<string>::iterator s = reptiloid.begin(); s!=reptiloid.end();s++)
{
if (g == f)
{
cout << endl << "selected: " << *s;
reptiloid.erase(s);
break;
}
g++;
}
cout << endl << endl;
for (const auto& s : reptiloid)
{
cout << s << endl;
}
cout << endl << endl;
return 0;
}