#include typedef unsigned int uint; // from cube2, zlib licensed #define N (624) #define M (397) #define K (0x9908B0DFU) static uint state[N]; static int next = N; void seedMT(uint seed) { state[0] = seed; for (uint i = 1; i < N; i++) // if we do not do this precisely, at least we // should coerce to int immediately, not wait state[i] = seed = 1812433253U * (seed ^ (seed >> 30)) + i; next = 0; } int main() { seedMT(5497); for (int i = 0; i < 10; i++) printf("%d: %u\n", i, state[i]); return 0; }