I created a function to create a random matrix containing 0 and 1 in C ++ using srand and rand but I didn’t know how I can indicate that in each matrix I need the same number 1, for example 5. I thought about to put a variable that counts the number 1, and if they are less than or greater than 5, to adjust the matrix, but I was wondering if there is a much faster solution. Thanks
source share