#include <cstdlib>
#include <iostream>
#include <windows.h>
using namespace std;
char map2char[]={'1','2','3','4','5','6','7','8','b','c','d','e','f','g','h','i',
'j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y'};
void getbit( unsigned e, char *s, int offset ){
int i=17;
while( i>=0 ){
s[18*offset+i]=((e>>i)&1);
--i;
}
}
int main(int argc, char *argv[])
{
srand(GetTickCount());
char bit[90], S[90];
for( int i=0; i<sizeof(bit); ++i ) bit[i]=0, S[i]=0;
unsigned x, T;
for( int k=0; k<5; ++k ){
do
x=rand();
while( x==0 );
getbit( x, S, k);
getbit( x, bit, k );
}
unsigned head=89;
unsigned j=0, time=GetTickCount(), Max=1000000;
do{
++j;
T=(bit[head]&1)^(bit[(head-83)%90]&1)^(bit[(head-84)%90]&1)^(bit[(head-86)%90]&1)^(bit[(head-89)%90]&1);
bit[head]=T;
head=(head+1)%90;
for( int index=0; index<18; ++index ){
int num=0;
for( int j=0; j<5; ++j )
num+=(bit[(head+5*index+j)%90]==0)? 0 : (1<<j);
cout<<map2char[num];
}
cout<<endl;
}while( j<Max );
cout<<"time: "<<GetTickCount()-time<<" ms!\n";
system("PAUSE");
return EXIT_SUCCESS;
}
#include <iostream>
#include <windows.h>
using namespace std;
char map2char[]={'1','2','3','4','5','6','7','8','b','c','d','e','f','g','h','i',
'j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y'};
void getbit( unsigned e, char *s, int offset ){
int i=17;
while( i>=0 ){
s[18*offset+i]=((e>>i)&1);
--i;
}
}
int main(int argc, char *argv[])
{
srand(GetTickCount());
char bit[90], S[90];
for( int i=0; i<sizeof(bit); ++i ) bit[i]=0, S[i]=0;
unsigned x, T;
for( int k=0; k<5; ++k ){
do
x=rand();
while( x==0 );
getbit( x, S, k);
getbit( x, bit, k );
}
unsigned head=89;
unsigned j=0, time=GetTickCount(), Max=1000000;
do{
++j;
T=(bit[head]&1)^(bit[(head-83)%90]&1)^(bit[(head-84)%90]&1)^(bit[(head-86)%90]&1)^(bit[(head-89)%90]&1);
bit[head]=T;
head=(head+1)%90;
for( int index=0; index<18; ++index ){
int num=0;
for( int j=0; j<5; ++j )
num+=(bit[(head+5*index+j)%90]==0)? 0 : (1<<j);
cout<<map2char[num];
}
cout<<endl;
}while( j<Max );
cout<<"time: "<<GetTickCount()-time<<" ms!\n";
system("PAUSE");
return EXIT_SUCCESS;
}