#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( )
{
string num_names[ 6 ] ;
int num_of_names = 0 ;
int seed;
int N = 6 ;
cout << "== Who Should I Text? ==" << endl;
cout << "Enter seed" << endl;
cin >> seed;
srand ( seed) ;
while ( std:: cout << "Enter friend " << num_of_names << endl,
std:: cin >> num_names[ num_of_names] )
{
++ num_of_names;
}
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+CiNpbmNsdWRlIDxjdGltZT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0cmluZyBnZXRfcmFuZG9tX25hbWUoc3RyaW5nIGFycltdLCBpbnQmIG51bXMpCnsKICAgIGludCBudW0gPSByYW5kKCkgJSBudW1zOwogICAgc3RyaW5nIG5hbWUgPSBhcnJbbnVtXTsKICAgIGFycltudW1dID0gYXJyW251bXMgLSAxXTsKICAgIC0tbnVtczsKICAgIHJldHVybiBuYW1lOwoKCn0KCmludCBtYWluKCkKewogICAgCiAgICBzdHJpbmcgbnVtX25hbWVzWzZdOwogICAgaW50IG51bV9vZl9uYW1lcyA9IDA7CiAgICBpbnQgc2VlZDsKICAgIGludCBOID0gNjsKCiAgICBjb3V0IDw8ICI9PSBXaG8gU2hvdWxkIEkgVGV4dD8gPT0iIDw8IGVuZGw7CiAgICBjb3V0IDw8ICJFbnRlciBzZWVkIiA8PCBlbmRsOwogICAgY2luID4+IHNlZWQ7CglzcmFuZChzZWVkKTsKICAgIHdoaWxlKHN0ZDo6Y291dCA8PCAiRW50ZXIgZnJpZW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