Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- const int NUM_OF_FACES = 6;
- const int NUM_ROLLS = 10000;
- int main() {
- int timeFacesAppeared[NUM_OF_FACES] = { 0 };
- srand(time(NULL));
- for (int i=0; i<NUM_ROLLS; i++) {
- int roll = rand() % NUM_OF_FACES + 1;
- timeFacesAppeared[roll - 1]++;
- }
- for (int face=1; face<=NUM_OF_FACES; face++) {
- printf("%d appeared %d times\n", face, timeFacesAppeared[face-1]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment