本程序基于Schrage的成果
#include<iostream>
using namespace std;
static unsigned int Seed=1;
const int A=48241;
const int M=2147483647;
const int Q=M/A;
const int R=M%A;
const int W=7;
double Random()
{
long TmpSeed=A*(Seed%Q)-R*(Seed/Q);
if(TmpSeed>=0)
Seed=TmpSeed;
else
Seed=TmpSeed+M;
return (int)((double)Seed/M*97)%W;
}
int main()
{
for(int i=10;i<30;i++)
cout<<Random()<<endl;
return 0;
}