C++ 井PRNG不工作?(可能)

C++ 井PRNG不工作?(可能),c++,random,static-libraries,prng,C++,Random,Static Libraries,Prng,我正在尝试使用WELL PRNG的一个具体实现,据说比原来的更好。 但是我有一些麻烦。无论我如何播种,它只输出相同的数字。我想我可能只是用错了,但还没能找出我的错误。不幸的是,PRNG的来源对我来说是完全不透明的 我的代码: #include <iostream> #include <WELL44497a_new.h> void pause() { std::string dummy; std::cout << "Press enter t

我正在尝试使用WELL PRNG的一个具体实现,据说比原来的更好。

但是我有一些麻烦。无论我如何播种,它只输出相同的数字。我想我可能只是用错了,但还没能找出我的错误。不幸的是,PRNG的来源对我来说是完全不透明的

我的代码:

#include <iostream>
#include <WELL44497a_new.h>

void pause()
{
    std::string dummy;
    std::cout << "Press enter to continue...";
    std::getline(std::cin, dummy);
}

int main(int argc, char** argv) {
    using std::cout;
    using std::cin;
    using std::endl;
    cout<<"Hello"<<endl;
    pause();
    unsigned int rngseed;
    cout<<"Input RNG seed:";
    cin>>rngseed;
    cout<<"The RNG seed is:";
    cout<<rngseed<<endl;
    pause();
    InitWELLRNG44497(&rngseed);
    int i=1;
    for (i;i<100;i++){
        unsigned long rngtest=WELLRNG44497();
        cout<<rngtest<<endl;
    }
    pause();
    return 0;
}
#包括
#包括
无效暂停()
{
字符串伪码;

std::cout根据注释squeamish ossifrage我已经修改了代码。以下代码似乎有效:

...
cin>>rngseed;
cout<<"The RNG seed is:";
cout<<rngseed<<endl;
pause();
unsigned int rngseed_arr[1391];
int i=0;
for (i;i<1391;i++){
    rngseed_arr[i]=rngseed+i;
}
InitWELLRNG44497(rngseed_arr);
i=1;
...
。。。
cin>>rngseed;

coutWell如果是您正在使用的代码,那么
InitWELLRNG44497()
看起来它需要一个1391
int
值的数组,而不仅仅是一个
int*
指针。这可能与此有关。@squeamish ossifrage你说得对!我更改了我的代码,从输入创建了一个数组,现在它似乎可以工作了。谢谢。如果你把它作为一个答案,而不是一个注释发布,我会的将其标记为答案。