Ror*_*oro 1 c++ random visual-studio-2010
我正在尝试将为UNIX编写的代码移植到Visual Studio,我收到以下错误
\random.cpp(29): error C3861: 'initstate': identifier not found
\random.cpp(37): error C3861: 'random': identifier not found
\random.cpp(49): error C3861: 'random': identifier not found
\random.cpp(51): error C3861: 'random': identifier not found
\random.cpp(63): error C3861: 'random': identifier not found
\random.cpp(78): error C3861: 'SQRT': identifier not found
\random.cpp(78): error C3861: 'LOG': identifier not found
\random.cpp(78): error C3861: 'COS': identifier not found
\random.cpp(87): error C3861: 'ABS': identifier not found
Run Code Online (Sandbox Code Playgroud)
代码很长但我已经包含math.h但我仍然遇到这些错误.可能这些功能仅限UNIX!如果是这样,我有什么选择呢?
这是我的代码的修改样本(给我错误的行);
if( NULL == initstate(2, rngState, 256) )
do something...
int r = (int)( (rangeEnd - rangeStart) * random() );
double z = SQRT(-2.0 * LOG(x1)) * COS(2.0 * M_PI * x2);
Run Code Online (Sandbox Code Playgroud)
SQRT - > sqrt
LOG - > log
COS - > cos
random- > rand(别忘# include <stdlib.h>了)
并写下initstate之前的主要或做出前瞻性声明.
| 归档时间: |
|
| 查看次数: |
7152 次 |
| 最近记录: |