Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. <?php
  2. function losBinC($bit=8)
  3. {
  4. $losbinC = "";
  5. for($bit=0;$bit<8;$bit++)
  6. $losbinC .= rand(0,1);
  7. return $losbinC;
  8. }
  9.  
  10. echo losBinC();
  11.  
  12. echo "<br><br>";
  13.  
  14. function losBinS($bit=8)
  15. {
  16.  
  17. $losBinS="";
  18. for($bit=0;$bit<8;$bit++)
  19. $losBinS .="01";
  20. $losBinS = substr(str_shuffle($losBinS),$bit);
  21. return $losBinS;
  22. }
  23. echo losBinS();
  24. echo "<br><br>";
  25.  
  26. function losBinD($bit=8){
  27. for($i=0;$i<=255;$i++)
  28. {
  29. $StatC[$i]=0;
  30. $StatS[$i]=0;
  31. }
  32. $ileLosow=50000;
  33. for($losowanko=0;$losowanko<$ileLosow;$losowanko++)
  34. {
  35. $statC[bindec(losBinC())]++
  36. $statS[bindec(losBinS())]++
  37.  
  38. }
  39. for($i=0;$i<255)
  40. {
  41. $AvgC+=$StatC[$i]*$i
  42.  
  43. }
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement