#ifndef MYRANDOMH #define MYRANDOMH class myrandom1 { unsigned long next; public: myrandom1(unsigned initial_next = 1): next(initial_next) {} int operator()() { next = next * 1103515245 + 12345; return static_cast(next / 65536) % 32768; } }; class myrandom2 { unsigned long next; public: myrandom2(unsigned initial_next = 1): next(initial_next) {++*this;} myrandom2& operator++() { next = next * 1103515245 + 12345; return *this; } int operator*() const { return static_cast(next / 65536) % 32768; } }; inline const myrandom2 operator++(myrandom2& r, int) { const myrandom2 old = r; ++r; return old; } struct str { unsigned long seed; int i; int random; }; static str s; class myrandom3 { unsigned long next; int i; public: myrandom3(unsigned initial_next = 1) : next(initial_next), i(-1) {s.seed = next; ++*this;} myrandom3& operator++() { next = next * 1103515245 + 12345; ++i; return *this; } str *operator->() const { s.i = i; s.random = static_cast(next / 65536) % 32768; return &s; } }; inline const myrandom3 operator++(myrandom3& r, int) { const myrandom3 old = r; ++r; return old; } #endif