Paste Search Dynamic
base was pct*100
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(void) {
  4.  
  5. #define BASE 40 //base crit percentage
  6. #define ITERATIONS 10000
  7.  
  8. int cnt = 0, inc=10;
  9. double pct = 0.0;
  10. srand(time(null));
  11.  
  12. for (int i = 0; i < ITERATIONS; i++)
  13. {
  14.         if (rand()%100 < (BASE + inc))
  15.         {
  16.                 cnt++;
  17.                 inc = 0;
  18.         }
  19.         else
  20.                 inc+=10;
  21.        
  22. }
  23. pct = (double)cnt/10000;
  24. printf ("Percetage of crit: %lf percent, base was: %d percent\n", pct*100, BASE);
  25.        
  26.  
  27.  
  28.  
  29.         return 0;
  30. }
  31.  
Parsed in 0.003 seconds