+ 1
What should I do if I want to call random values from an array?
Let's say I want my array to have these elements:{1,2,3,6} and I want to use the srand function for the elements from the array.Can it be done?
6 ответов
+ 6
I think you are talking about C++
+ 1
make an array
make a variable with a max random length of the array length
print array[x]
i used javascript
var arr = ["array1","array2"];
var x = Math.random()*arr.length;
console.log(arr[x]);
+ 1
Yes,I was speaking about C++
+ 1
So what options do we have in this case?
+ 1
Thanks a lot!