lundi 19 octobre 2020

Alternative loop replacing "while (true)" [closed]

For my college project I cannot use "while" or "break" in my code, what would be the best alternative for this block of code?

while(true)
{
    cout << "Seed for randomization(T)ime, (U)ser defined, (D)ebug mode : ";
    cin >> seed_type;
    if (seed_type == 't' || seed_type == 'T') 
    {
    seed = rand();
        srand((unsigned int)time(NULL));
        break;
    }
    if (seed_type == 'u' || seed_type == 'U') 
    {
        cout << "Write a number for the seed: ";
        cin >> seed_num;
        break;
    }
    if (seed_type == 'd' || seed_type == 'D') 
    {
        cout << "Write a number for the seed: ";
        cin >> seed_num;
        break;
    }
    cout << "Invalid Option\n";
}

Aucun commentaire:

Enregistrer un commentaire