Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. class TRandom {
  2. public:
  3. TRandom(int parameterA, int parameterB)
  4. : A_(parameterA)
  5. , B_(parameterB)
  6. , Cur_(0)
  7. {}
  8.  
  9. unsigned int Random() {
  10. return nextRand32();
  11. }
  12.  
  13. private:
  14. unsigned int nextRand24() {
  15. Cur_ = Cur_ * A_ + B_;
  16. return Cur_ >> 8;
  17. }
  18. unsigned int nextRand32() {
  19. unsigned int aa = nextRand24(), bb = nextRand24();
  20. return (aa << 8) ^ bb;
  21. }
  22.  
  23. private:
  24. int A_, B_;
  25. unsigned int Cur_;
  26. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement