As I understand it, the "professions", that the names will always be one number. Then simply mix each array, and then output them.
The function shuffle (> = C ++ 11) or random_shuffle (> = C ++ 98) from the standard library will help. As a generator, use one suitable for you ( http://www.cplusplus.com/reference/random/ , look for the Generators heading).
Code :
#include <iostream> // std::cout #include <algorithm> // std::shuffle #include <array> // std::array #include <random> // std::default_random_engine #include <chrono> // std::chrono::system_clock using namespace std; int main () { // Help to keep same size using Array = array<string, 3>; Array names = { "Alexandr", "Kostya", "Roman" }; Array work = { "Stoloter", "Posudomoyka", "Shef" }; // obtain a time-based seed: unsigned seed = chrono::system_clock::now().time_since_epoch().count(); // shuffle both arrays shuffle(begin(names), end(names), std::default_random_engine(seed)); // Update seed and shuffle other array seed = chrono::system_clock::now().time_since_epoch().count() + 1; shuffle(begin(work), end(work), std::default_random_engine(seed)); for (size_t idx = 0; idx < names.size(); ++idx) { cout << names[idx] << ' ' << work[idx] << '\n'; } return 0; }
Exhaust on different starts may be:
$ ./a.out Kostya Shef Roman Stoloter Alexandr Posudomoyka $ ./a.out Kostya Posudomoyka Roman Stoloter Alexandr Shef $ ./a.out Alexandr Stoloter Kostya Shef Roman Posudomoyka