dimanche 16 septembre 2018

Create a vector of size x with two numbers randomly divided

I currently need to create an array of size x and fill it with either 1s or -1s randomly divided. I can easily create an array and fill it with randint but the problem with that would be that I do not want 0s in my array.

I also have a precise number of the length of the array so I need to make sure that I have in total 100 or 1000 ints in it.

If anyone knows how to solve this smoothly it would be very much appreciated.

Thanks




Aucun commentaire:

Enregistrer un commentaire