SHARE
TWEET

Untitled

a guest Oct 14th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top