subject_41238.htm

来自「一些关于vc的问答」· HTM 代码 · 共 12 行

HTM
12
字号
<p>
序号:41238 发表者:白云飞扬 发表日期:2003-05-25 13:34:10
<br>主题:C++里怎么产生随机数?
<br>内容:#include&lt;stdlib.h&gt;<BR>#include&lt;time.h&gt;<BR><BR>main()<BR>{<BR>&nbsp;&nbsp;int i;<BR>&nbsp;&nbsp;randomize();<BR>&nbsp;&nbsp;i=random(30);&nbsp;&nbsp; //产生从0-29的随机数<BR>}<BR>&nbsp;&nbsp;<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 + =
减小字号Ctrl + -
显示快捷键?