cout << "Welcome!\n\n";
cout << "Type 4 girl names.\n";
for (int gi = 0; gi < 4; gi++)
cin >> g[gi];
cout << "Type 4 boy names.\n";
for (int bi = 0; bi < 4; bi++)
cin >> b[bi];
cout << "\nWhat they do (enter 4 actions)?\n";
for (int ai = 0; ai < 4; ai++)
getline(cin, a[ai]);
cout << "\nWhere is happening (enter 4 locations)?\n";
for (int li = 0; li < 4; li++)
getline(cin, l[li]);
for (int c = 0; c < 4; c++)
cout << g[rand() % 4] << " and " << b[rand() % 4] << " are " << a[rand() % 4] << " from a " << l[rand() % 4] << endl;
return (0);
}
At the end in the 4 lines some of the names, actions and locations repeat. How do I make them to not repeat and use every name that you will enter? do I need random_shuffle? How can I integrate it in my code?
Bookmarks