Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <time.h>
- #include <stdio.h>
- #include <limits.h>
- #include <stdlib.h>
- #define N_ITERATIONS 20000
- int main(){
- unsigned long int i, j, k, count, thresh, two_streak=0, total=0;
- double avg_sum=0;
- srand((unsigned)time(NULL));
- for(i=0;i<N_ITERATIONS;i++){
- thresh = rand();
- for(j=0;j<N_ITERATIONS;j++){
- count=0;
- for(k=0;k<14;k++){
- if(rand()<thresh)
- count++;
- }
- if(count==10){
- if(rand()<thresh && rand()<thresh)
- two_streak++;
- total++;
- }
- }
- }
- printf("%lf\n", (double)two_streak/(double)total);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement