0

How can you generate random numbers for an array on C++

I wanted to randomize a array of numbers on C++ but I can’t seem to find a way to do it. Anybody got a suggestion?

12th Aug 2019, 5:00 PM
Dani
2 ответов
+ 1
headers <cstdlib> , <ctime> , and functions srand() , and rand(). and you can use loop to fill array http://www.cplusplus.com/reference/cstdlib/rand/
12th Aug 2019, 7:34 PM
electron
electron - avatar
0
Are trying to generate random numbers and then assign them to an array or are you trying to randomly re-arrange the order the elements within an array? Anyway,...look up 'random_shuffle' from the <algorithm> header file.
12th Aug 2019, 7:41 PM
rodwynnejones
rodwynnejones - avatar