📄 subject_41238.htm
字号:
<p>
序号:41238 发表者:白云飞扬 发表日期:2003-05-25 13:34:10
<br>主题:C++里怎么产生随机数?
<br>内容:#include<stdlib.h><BR>#include<time.h><BR><BR>main()<BR>{<BR> int i;<BR> randomize();<BR> i=random(30); //产生从0-29的随机数<BR>}<BR> <BR>提示错误:undeclared identifier<BR>难道是头文件包含错误?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:theta 回复日期:2003-05-25 15:32:53
<br>内容:srand( (unsigned)time( NULL ) );<BR>i = rand()%30;
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -