samedi 22 août 2020

Get confused by for loop with srand

I try to print out all the random number.

And there should be 100000 lines.

but when I count the line, there's only 9000 lines.

I was very confused why there are some missing line.

Hope someone can help me.

    srand(114);
    double b=0;
    for(int i = 0;i<1000;i++){
            for(int j =0 ;j<10;j++){
                for(int k=0;k<10;k++){
                    b=double(rand()/(RAND_MAX+1.0));
                    cout<<b<<endl;
                }
            }
        } 



Aucun commentaire:

Enregistrer un commentaire