123456789101112131415161718192021222324252627282930
#include <iostream> size_t index {}; size_t MAX = 4; void mysrand( size_t x ) { index = x % MAX; } int myrand() { static int foo[] { 1, 3, 0, 2 }; auto result = foo[index++]; index %= MAX; return result; } int main() { for ( int y=0; y<6; ++y ) { std::cout << ' ' << myrand(); } std::cout << '\n'; mysrand( 7 ); for ( int y=0; y<6; ++y ) { std::cout << ' ' << myrand(); } std::cout << '\n'; }
<random>