All pastes #434738 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-04-11 15:59 UTC
rendered paste body
 #include <stdlib.h> 
 #include <time.h> 
 #include <math.h> 
#include <stdafx.h>
  
 int rollDice(void); 
 int actual [11] = {0}; 
 int expected [11] = {1000,2000,3000,4000,5000,6000,5000,4000,3000,2000,1000}; 
  
 int main(void) { 
     int rollValue=0; 
     srand( time ( NULL ) ); 
     for (int x=0; x<36000; x++) { 
             rollValue = rollDice() + rollDice(); 
             actual[rollValue-2]++; 
     } 
     printf("Sum\t\tTotal\t\tExpected\t\t Actual\n"); 
     for (int x=0; x<11; x++) { 
          
           printf("%3d\t\t",x+2); 
           printf("%5d\t\t",actual[x]); 
           printf("%7.3f%%\t\t",((float) expected[x]/360)); 
           printf("%6.3f%%\n",( (float) actual[x]/360) ); 
     } 
  
     return 0; 
 } 
  
 int rollDice(void) { 
      
     return (1 + rand()%6); 
 }