#include #include #include #include #include using namespace std; vector con, red, green, yellow; int n, m, t, idx, tmp, val; string s = 'aA0'; vector v; string usergen(int inp) { stringstream ss; ss << inp; return "Contestant" + ss.str(); } string passgen() { string str(8, ' '); v.clear(); a[0] = rand() % 26; a[1] = rand() % 26; a[2] = rand() % 10; for (int I = 0; I < 8; ++I) v.push_back(I); for (int I = 0; I < 3; ++I) { idx = rand() % v.size(); tmp = v[idx]; v.erase(v.begin() + idx, 1); str[idx] = s[0] + a[I]; } for (int I = 0; I < 8; ++I) if (str[I] == ' ') { tmp = rand() % 52; x = tmp / 26; tmp %= 26; str[I] = s[x] + tmp; } return str; } int main () { srand(time(0)); red.push_back(3); red.push_back(6); green.push_back(0); green.push_back(1); green.push_back(5); yellow.push_back(2); yellow.push_back(4); yellow.push_back(7); for (int I = 8; I < 15; ++I) con.push_back(I); for (int I = 1; I <= 15; ++I) { n = (I - 1) % 3; switch (n) { case 0: // yellow cout << "Yellow\t\t"; if (yellow.size()) { t = rand() % yellow.size(); cout << yellow[t] << " "; yellow.erase(yellow.begin() + t, 1); } else { t = rand() % con.size(); cout << con[t] << " "; con.erase(con.begin() + t, 1); } break; case 1: // green cout << "Green\t\t"; if (green.size()) { t = rand() % green.size(); cout << green[t] << "\t\t"; green.erase(green.begin() + t, 1); } else { t = rand() % con.size(); cout << con[t] << "\t\t"; con.erase(con.begin() + t, 1); } break; default: // red cout << "Red\t\t"; if (red.size()) { t = rand() % red.size(); cout << red[t] << "\t\t"; red.erase(red.begin() + t, 1); } else { t = rand() % con.size(); cout << con[t] << "\t\t"; con.erase(con.begin() + t, 1); } } cout << usergen(I) << "\t\t"; cout << passgen() << endl; } return 0; }