Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5.  
  6.  
  7.  
  8. void main(void)
  9. {
  10. int tries=0,total=0,sum2=0,items,chance,attempts,number,unique,sample,unique_obtained=0,obtained = 0;
  11. int i,j,k,l;
  12. int unique_greater=0,total_greater=0;
  13. printf("Please enter number of items to test: ");
  14. scanf("%d",&items);
  15. printf("What is the chance of item(1/#): ");
  16. scanf("%d",&chance);
  17. printf("How many kills/attempts: ");
  18. scanf("%d",&attempts);
  19. printf("Sample size: ");
  20. scanf("%d",&sample);
  21. printf("Current # of items: ");
  22. scanf("%d",&number);
  23. printf("# of unique items: ");
  24. scanf("%d",&unique);
  25.  
  26. for(i=0;i<sample;i++)
  27. {
  28. total = 0;
  29. unique_obtained = 0;
  30. for(k=0;k<items;k++)
  31. {
  32. obtained = 0;
  33. for(j=0;j<attempts;j++)
  34. {
  35. l = !(rand()%chance);
  36. total = total + l;
  37. if(l)
  38. {
  39. obtained=1;
  40.  
  41. }
  42.  
  43. }
  44. unique_obtained = unique_obtained + obtained;
  45. }
  46. if(total>number)
  47. total_greater++;
  48. if(unique_obtained>unique)
  49. unique_greater++;
  50. }
  51. float q,r;
  52. q = total_greater/sample;
  53. r = unique_greater/sample;
  54. printf("%d obtained more drops than you\n",total_greater);
  55. printf("%d obtained more unique items than you\n", unique_greater);
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement