#include #include typedef unsigned int word; word seed[10] = { 0 }, result[256], result_count, mm[256], aa, bb, cc, i, x, y, j, w; word Isaac() { if( !result_count-- ) { bb += ++cc; for(i = 0; i < 256; result[i++] = bb = mm[(y >> 10) & 255] + x) { x = mm[i]; aa ^= (i & 1) ? aa >> ((i & 2) ? 16 : 6) : aa << ((i & 2) ? 2 : 13); mm[i] = y = mm[(x >> 2) & 255] + (aa += mm[(i + 128) & 255]) + bb; } result_count = 255; } return result[result_count]; } void Init() { for(j = 0; j < 256; mm[j++] = 0); for(j = 0; j < sizeof(seed) / 4; j++) mm[j & 255] ^= seed[j]; for(j = aa = bb = cc = result_count = 0; j < 1 << 24; j++) Isaac(); j = w = 0; } int main() { gettimeofday((struct timeval*)seed, NULL); Init(); for(j = 0; j < 10; j++) printf("%30u\n", Isaac()); return 0; }