Guest User

Untitled

a guest
Mar 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.88 KB | None | 0 0
  1. #include <cstdlib>
  2.  
  3. #include <iostream>
  4.  
  5. #include <time.h>
  6.  
  7.  
  8.  
  9. using namespace std;
  10.  
  11.  
  12.  
  13. int main(int argc, char *argv[])
  14.  
  15. {
  16.  
  17. int num1[6],a[50]={0},k;
  18.  
  19. srand(time(NULL));
  20.  
  21. for(int count=0;count<10000;count++)
  22.  
  23. {
  24.  
  25. for(int i=0;i<6;i++)
  26.  
  27. {
  28.  
  29. num1[i]=rand()%50;
  30.  
  31. for(int j=0;j<i;j++)
  32.  
  33. if(num1[i]==num1[j]) {i--;break;}
  34.  
  35. }
  36.  
  37.  
  38.  
  39. for(int i=0;i<6;i++)
  40.  
  41. {
  42.  
  43. k=num1[i];
  44.  
  45. a[k]++;
  46.  
  47. }
  48.  
  49. }
  50.  
  51.  
  52.  
  53. for(int k=0;k<50;k++)
  54.  
  55. {
  56.  
  57. cout<<k<<'\t'<<a[k]<<'\n';
  58.  
  59. }
  60.  
  61.  
  62.  
  63. int b1,b2,b3,b4,b5,b6;
  64.  
  65. int tempb1=0,tempb2=0,tempb3=0,tempb4=0,tempb5=0,tempb6=0;
  66.  
  67. for(k=0;k<50;k++)
  68.  
  69. {
  70.  
  71. if(a[k]>tempb1){tempb1=a[k];b1=k;}
  72.  
  73. if(a[k]>tempb2 && a[k]<=tempb1 && k!=b1){tempb2=a[k];b2=k;}
  74.  
  75. if(a[k]>tempb3 && a[k]<=tempb2 && k!=b1 && k!=b2){tempb3=a[k];b3=k;}
  76.  
  77. if(a[k]>tempb4 && a[k]<=tempb3 && k!=b1 && k!=b2 && k!=b3){tempb4=a[k];b4=k;}
  78.  
  79. if(a[k]>tempb5 && a[k]<=tempb4 && k!=b1 && k!=b2 && k!=b3 && k!=b4){tempb5=a[k];b5=k;}
  80.  
  81. if(a[k]>tempb6 && a[k]<=tempb5 && k!=b1 && k!=b2 && k!=b3 && k!=b4 && k!=b5){tempb6=a[k];b6=k;}
  82.  
  83. }
  84.  
  85.  
  86.  
  87. int s1,s2,s3,s4,s5,s6;
  88.  
  89. int temps1=10000,temps2=10000,temps3=10000,temps4=10000,temps5=10000,temps6=10000;
  90.  
  91. for(k=0;k<50;k++)
  92.  
  93. {
  94.  
  95. if(a[k]<temps1){temps1=a[k];s1=k;}
  96.  
  97. if(a[k]<temps2 && a[k]>=temps1 && k!=s1){temps2=a[k];s2=k;}
  98.  
  99. if(a[k]<temps3 && a[k]>=temps2 && k!=s1 && k!=s2){temps3=a[k];s3=k;}
  100.  
  101. if(a[k]<temps4 && a[k]>=temps3 && k!=s1 && k!=s2 && k!=s3){temps4=a[k];s4=k;}
  102.  
  103. if(a[k]<temps5 && a[k]>=temps4 && k!=s1 && k!=s2 && k!=s3 && k!=s4){temps5=a[k];s5=k;}
  104.  
  105. if(a[k]<temps6 && a[k]>=temps5 && k!=s1 && k!=s2 && k!=s3 && k!=s4 && k!=s5){temps6=a[k];s6=k;}
  106.  
  107. }
  108.  
  109.  
  110.  
  111. cout<<'\n'<<"以上為隨機一萬次,各數字出現次數"<<'\n';
  112.  
  113. cout<<'\n'<<"中獎機率最高的六個數為"<<b1<<'\,'<<b2<<'\,'<<b3<<'\,'<<b4<<'\,'<<b5<<'\,'<<b6<<'\n';
  114.  
  115. cout<<'\n'<<"中獎機率最低的六個數為"<<s1<<'\,'<<s2<<'\,'<<s3<<'\,'<<s4<<'\,'<<s5<<'\,'<<s6<<'\n';
  116.  
  117.  
  118.  
  119.  
  120.  
  121. int num2[6];
  122.  
  123. float sameb1,sameb2,sameb3,sameb4,sameb5,sameb6;
  124.  
  125. float sames1,sames2,sames3,sames4,sames5,sames6;
  126.  
  127.  
  128.  
  129. srand(time(NULL));
  130.  
  131. for(int count=0;count<10000;count++)
  132.  
  133. {
  134.  
  135. for(int i=0;i<6;i++)
  136.  
  137. {
  138.  
  139. num2[i]=rand()%50;
  140.  
  141. for(int j=0;j<i;j++)
  142.  
  143. if(num2[i]==num2[j]) {i--;break;}
  144.  
  145. }
  146.  
  147.  
  148.  
  149. int tempb=0,temps=0;
  150.  
  151.  
  152.  
  153. for(int i=0;i<6;i++)
  154.  
  155. {
  156.  
  157. if(b1=num2[i]){tempb++;}
  158.  
  159. if(b2=num2[i]){tempb++;}
  160.  
  161. if(b3=num2[i]){tempb++;}
  162.  
  163. if(b4=num2[i]){tempb++;}
  164.  
  165. if(b5=num2[i]){tempb++;}
  166.  
  167. if(b6=num2[i]){tempb++;}
  168.  
  169. }
  170.  
  171. if(tempb==1){sameb1++;}
  172.  
  173. if(tempb==2){sameb2++;}
  174.  
  175. if(tempb==3){sameb3++;}
  176.  
  177. if(tempb==4){sameb4++;}
  178.  
  179. if(tempb==5){sameb5++;}
  180.  
  181. if(tempb==6){sameb6++;}
  182.  
  183.  
  184.  
  185. for(int i=0;i<6;i++)
  186.  
  187. {
  188.  
  189. if(s1=num2[i]){temps++;}
  190.  
  191. if(s2=num2[i]){temps++;}
  192.  
  193. if(s3=num2[i]){temps++;}
  194.  
  195. if(s4=num2[i]){temps++;}
  196.  
  197. if(s5=num2[i]){temps++;}
  198.  
  199. if(s6=num2[i]){temps++;}
  200.  
  201. }
  202.  
  203. if(temps==1){sames1++;}
  204.  
  205. if(temps==2){sames2++;}
  206.  
  207. if(temps==3){sames3++;}
  208.  
  209. if(temps==4){sames4++;}
  210.  
  211. if(temps==5){sames5++;}
  212.  
  213. if(temps==6){sames6++;}
  214.  
  215.  
  216.  
  217. for(int i=0;i<6;i++)
  218.  
  219. {
  220.  
  221. k=num2[i];
  222.  
  223. a[k]++;
  224.  
  225. }
  226.  
  227.  
  228.  
  229. }
  230.  
  231.  
  232.  
  233. float prosameb1,prosameb2,prosameb3,prosameb4,prosameb5,prosameb6;
  234.  
  235. float prosames1,prosames2,prosames3,prosames4,prosames5,prosames6;
  236.  
  237. float totprosameb,totprosames;
  238.  
  239.  
  240.  
  241. prosameb1=sameb1/100;
  242.  
  243. prosameb2=sameb2/100;
  244.  
  245. prosameb3=sameb3/100;
  246.  
  247. prosameb4=sameb4/100;
  248.  
  249. prosameb5=sameb5/100;
  250.  
  251. prosameb6=sameb6/100;
  252.  
  253.  
  254.  
  255. prosames1=sames1/100;
  256.  
  257. prosames2=sames2/100;
  258.  
  259. prosames3=sames3/100;
  260.  
  261. prosames4=sames4/100;
  262.  
  263. prosames5=sames5/100;
  264.  
  265. prosames6=sames6/100;
  266.  
  267.  
  268.  
  269. totprosameb=prosameb1+prosameb2+prosameb3+prosameb4+prosameb5+prosameb6;
  270.  
  271. totprosames=prosames1+prosames2+prosames3+prosames4+prosames5+prosames6;
  272.  
  273.  
  274.  
  275. cout<<'\n';
  276.  
  277.  
  278.  
  279. cout<<"選擇機率高的投注,中一個數的次數為"<<sameb1<<"機率為"<<prosameb1<<"%"<<'\n';
  280.  
  281. cout<<"選擇機率高的投注,中兩個數的次數為"<<sameb2<<"機率為"<<prosameb2<<"%"<<'\n';
  282.  
  283. cout<<"選擇機率高的投注,中三個數的次數為"<<sameb3<<"機率為"<<prosameb3<<"%"<<'\n';
  284.  
  285. cout<<"選擇機率高的投注,中四個數的次數為"<<sameb4<<"機率為"<<prosameb4<<"%"<<'\n';
  286.  
  287. cout<<"選擇機率高的投注,中五個數的次數為"<<sameb5<<"機率為"<<prosameb5<<"%"<<'\n';
  288.  
  289. cout<<"選擇機率高的投注,中六個數的次數為"<<sameb6<<"機率為"<<prosameb6<<"%"<<'\n';
  290.  
  291.  
  292.  
  293. cout<<'\n';
  294.  
  295.  
  296.  
  297. cout<<"選擇機率低的投注,中一個數的次數為"<<sames1<<"機率為"<<prosames1<<"%"<<'\n';
  298.  
  299. cout<<"選擇機率低的投注,中兩個數的次數為"<<sames2<<"機率為"<<prosames2<<"%"<<'\n';
  300.  
  301. cout<<"選擇機率低的投注,中三個數的次數為"<<sames3<<"機率為"<<prosames3<<"%"<<'\n';
  302.  
  303. cout<<"選擇機率低的投注,中四個數的次數為"<<sames4<<"機率為"<<prosames4<<"%"<<'\n';
  304.  
  305. cout<<"選擇機率低的投注,中五個數的次數為"<<sames5<<"機率為"<<prosames5<<"%"<<'\n';
  306.  
  307. cout<<"選擇機率低的投注,中六個數的次數為"<<sames6<<"機率為"<<prosames6<<"%"<<'\n';
  308.  
  309.  
  310.  
  311. cout<<'\n';
  312.  
  313.  
  314.  
  315. cout<<"投注機率高的中獎機率為"<<totprosameb<<"%"<<'\n';
  316.  
  317. cout<<"投注機率低的中獎機率為"<<totprosames<<"%"<<'\n';
  318.  
  319.  
  320.  
  321. cout<<'\n';
  322.  
  323.  
  324.  
  325. if(totprosameb>totprosames)
  326.  
  327. {cout<<"投注機率高的中獎機率高"<<'\n';}
  328.  
  329.  
  330.  
  331. if(totprosameb<totprosames)
  332.  
  333. {cout<<"投注機率低的中獎機率高"<<'\n';}
  334.  
  335.  
  336.  
  337. if(totprosameb==totprosames)
  338.  
  339. {cout<<"投注機率高的與投注機率低的中獎機率一樣"<<'\n';}
  340.  
  341.  
  342.  
  343. cout<<'\n';
  344.  
  345.  
  346.  
  347. system("PAUSE");
  348.  
  349.  
  350.  
  351. }
Add Comment
Please, Sign In to add comment