#include #include #include #include using namespace std; vector parse_expression(string expression) { //parses expression with " " being the delimeter vector results; string s; for(unsigned int i = 0; i < expression.length(); i++) { char c = expression[i]; if(c != ' ') { s += c; } else { if(s != "") { results.push_back(s); s.clear(); } } } if(s != "") { results.push_back(s); } return results; } bool has_a(vector list, string name) { for(unsigned int i = 0; i < list.size(); i++) { if(list[i] == name) return true; } return false; } int main() { srand(time(NULL)); cout << "Please enter names with a space inbetween each player: "; string names; getline(cin, names); vector list = parse_expression(names); vector result; while(result.size() != list.size()) { int rand_m; while(rand_m != 50) { rand_m = rand() % 10000; } int rand_n = rand() % list.size(); string adding = list[rand_n]; if(!has_a(result, adding)) { result.push_back(adding); } } cout << "This is the order: " << endl; for(unsigned int i = 0; i < result.size(); i++) { cout << i + 1 << ") " << result[i] << endl; } }