#ifndef MYRANDH #define MYRANDH #include //for iterator_traits using namespace std; class myrand: public iterator { unsigned long next; public: myrand(unsigned initial_next = 1): next(initial_next) {++*this;} int operator*() const { return static_cast(next / 65536) % 32768; } myrand& operator++() { next = next * 1103515245 + 12345; return *this; } const myrand operator++(int) { const myrand old = *this; ++*this; return old; } friend bool operator==(const myrand& it1, const myrand& it2) { return false; } }; inline bool operator!=(const myrand& it1, const myrand& it2) { return !(it1 == it2); } #endif