#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
string get_random_name( string arr[ ] , int & nums)
{
int num = rand ( ) % nums;
string name = arr[ num] ;
arr[ num] = arr[ nums - 1 ] ;
-- nums;
return name;
}
int main( )
{
srand ( time ( NULL ) ) ;
string num_names[ 6 ] ;
int num_of_names;
int N = 6 ;
cout << "== Who Should I Text? ==" << endl;
cout << "Enter seed" << endl;
cin >> num_of_names;
for ( int counter = 0 ; counter < num_of_names; counter++ )
{
cout << "Enter friend " << counter << endl;
cin >> num_names[ counter] ;
}
cout << "You should text: " << get_random_name( num_names, num_of_names) << endl;
cout << "These other friends didn't make the cut:" << endl;
for ( int i = 0 ; i < num_of_names; ++ i)
{
cout << num_names[ i] << endl;
}
return 0 ;
}
CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxjdGltZT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0cmluZyBnZXRfcmFuZG9tX25hbWUoc3RyaW5nIGFycltdLCBpbnQmIG51bXMpCnsKICAgIGludCBudW0gPSByYW5kKCkgJSBudW1zOwogICAgc3RyaW5nIG5hbWUgPSBhcnJbbnVtXTsKICAgIGFycltudW1dID0gYXJyW251bXMgLSAxXTsKICAgIC0tbnVtczsKICAgIHJldHVybiBuYW1lOwoKCn0KCmludCBtYWluKCkKewogICAgc3JhbmQodGltZShOVUxMKSk7CiAgICBzdHJpbmcgbnVtX25hbWVzWzZdOwogICAgaW50IG51bV9vZl9uYW1lczsKICAgIGludCBOID0gNjsKCiAgICBjb3V0IDw8ICI9PSBXaG8gU2hvdWxkIEkgVGV4dD8gPT0iIDw8IGVuZGw7CiAgICBjb3V0IDw8ICJFbnRlciBzZWVkIiA8PCBlbmRsOwogICAgY2luID4+IG51bV9vZl9uYW1lczsKCiAgICBmb3IgKGludCBjb3VudGVyID0gMDsgY291bnRlciA8IG51bV9vZl9uYW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