Anyone tried to beat roulette game? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Anyone tried to beat roulette game?

Im tring to make a code that could get some statistics out of example 10000 random numbers ranging from 0 to 36 any help?

10th Oct 2017, 12:30 AM
Antoine Sayah
Antoine Sayah - avatar
8 Answers
+ 11
"...10000 random numbers ranging from 0 to 36..." // after declaring appropriate headers and seeding RNG for (int i = 0; i < 10000; i++) std::cout << rand() % 37 << " "; // if you want to keep track of the number of hits on each number, use an array. int arr[37]; for (int i = 0; i < 37; i++) arr[i] = 0; // now, for each hit, you want to increment the array element for the corresponding number by one. // reusing the loop earlier for (int i = 0; i < 10000; i++) arr[rand() % 37] += 1; // now you have recorded all the number of 0, 1, 2, ... 36s which has been hit. // print them out. for (int i = 0; i < 37; i++) std::cout << arr[i] << " ";
10th Oct 2017, 2:18 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
In what language
10th Oct 2017, 12:32 AM
Joshua
Joshua - avatar
+ 1
c++
10th Oct 2017, 12:32 AM
Antoine Sayah
Antoine Sayah - avatar
0
Well sorry, can't help ya there
10th Oct 2017, 12:37 AM
Joshua
Joshua - avatar
0
you have something for roulette but in other languages?
10th Oct 2017, 12:38 AM
Antoine Sayah
Antoine Sayah - avatar
0
i can code if you could just point out some ideas
10th Oct 2017, 12:44 AM
Antoine Sayah
Antoine Sayah - avatar
0
Roll from 0 to 36 ten thousand times and keep the track of each number chosen. Then, rearrange them in ascending order, and count the percent chance of getting each of them by proportion times chosen/all tries = chance/100 So you need to find a chance. Do you want more?
10th Oct 2017, 12:47 AM
Freezemage
Freezemage - avatar
0
well I have one in js, but you knda have to understand it
10th Oct 2017, 8:18 PM
Joshua
Joshua - avatar