急求高人指点!! 用1-10 这10个数字产生20个随机数,如何实现?

2024-12-29 01:29:15
推荐回答(2个)
回答1:

输入下列公式就可以了:

=INT(1+RAND()*10)

其中RAND()是EXCEL中的随机函数,产生0-1之间的随机数,将其扩大10后加1取整就得到1-10之间的随机数

没看清楚楼主要求,有点难

回答2:

随机生成双色球号码
void CSuiJiDlg::OnOK()
{
// TODO: Add extra validation here
int a1,a2,a3,a4,a5,a6,b7;
srand( (unsigned)time( NULL ) ); //
a1=rand()%32+1;
Sleep(a1*100);
srand((unsigned)a1+(unsigned)time( NULL ));
a2=rand()%32+1;
Sleep(a2*100);
srand((unsigned)a2+(unsigned)time( NULL ));
a3=rand()%32+1;
Sleep(a3*100);
srand((unsigned)a3+(unsigned)time( NULL ));
a4=rand()%32+1;
Sleep(a4*100);
srand((unsigned)a4+(unsigned)time( NULL ));
a5=rand()%32+1;
Sleep(a5*100);
srand((unsigned)a5+(unsigned)time( NULL ));
a6=rand()%32+1;

Sleep(a6*100);
srand((unsigned)a6+(unsigned)time( NULL ));
b7=rand()%15+1;
CString text;
text.Format(_T("%d %d %d %d %d %d +%d"),a1,a2,a3,a4,a5,a6,b7);
MessageBox(text);
}