请问如何生成一个0,1的随机数和0~5之间的随机数???
解决方案 »
- 局域网传输收的文件损坏
- 易语言 == Visual C++ 6.0
- skinmagic 运行的时候出现 debug assertion failed
- WndProc的错误VC6.0++总提示:local function definitions are illegal(附源程序)
- 如何在编辑框中接受ENTER指令
- ISDN拨号问题???
- 如何在改变窗口大小时,固定比例变化!
- 看似简单的一个问题
- 帮帮我呀,如何判断加锁是否成功-lockrange()?需要捕捉异常吗?
- 求问,本人用MFC程序控制摄像头捕捉图像,重启电脑后可以实现,程序关闭再次运行时却捕捉不到了,是出自于什么原因?
- 为什么CMap<long,long,CMySocket*,CMySocket*> IDtoSocket;不能作为类的成员?
- 怎样得到Doc的指针
Rand()%9
好象是这样的,我看看
应为rand,示例
void CTestDlg::OnButton1()
{
// TODO: Add your control notification handler code here
int a=0,b=0,c=0,d=0,e=0;
a=rand()%9;
b=rand()%9;
c=rand()%9;
d=rand()%9;
e=rand()%9; CString str;
str.Format("%d,%d,%d,%d,%d",a,b,c,d,e);
AfxMessageBox(str);
}
#include <stdio.h>
#include <time.h>void main( void )
{ /* Seed the random-number generator with current time so that
* the numbers will be different every time we run.
*/
srand( (unsigned)time( NULL ) ); /* Display numbers. */
printf( " %d\n", rand() );
}