lundi 6 juillet 2020

regeneration of random number

I'm beginner in c++. I need to regenerate the same random number as it will be different under the below condition. How can I do it? Thank you!

int x = rand() % ((n_p)- 0 + 1) + 0;

if (A[x][0] == A[x][1])
{
    // regenerate x as it will be different.

    int x = rand() % ((n_p) - 0 + 1) + 0;
    
}



Aucun commentaire:

Enregistrer un commentaire