Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define RARE_PROBABILITY 5
- #define NUM_OF_RARE_CARD 6
- int card[NUM_OF_RARE_CARD], i;
- int is_complete(){
- for(i=0;i<NUM_OF_RARE_CARD;i++)
- if(!card[i])
- return 0;
- return 1;
- }
- main(){
- int n = 0, i, p;
- srand(time(0));
- while(!is_complete()){
- // congrats! you've got a rare card
- if((p =rand() % 100) < NUM_OF_RARE_CARD * RARE_PROBABILITY)
- card[p % NUM_OF_RARE_CARD]++;
- n++;
- }
- printf("%d\n", n); // print the number of tries
- }
Advertisement
Add Comment
Please, Sign In to add comment