饥荒千年狐属性修改:编写一个程序,计算福利奖券36选7的所有组合

来源:百度文库 编辑:高考问答 时间:2024/04/20 01:11:10
使用c语言实现,谢谢拉!本人急用!~~~~
#include <stdio.h>
void main()
{
float count=1;
int i=36;
while(true)
{
count*=i;
i--;
if(i==29)
{
count*=36;
break;
}
}
printf("%.0f",count);
}
中的ture是什么东西,连定义都没有定义,能用吗???

# include <stdlib.h>
# include <stdio.h>

main()
{

int i;
int n=1,m=36,k;
srand((unsigned)time(NULL));
for(i=0;i<7;i++)
{
k=rand()%(m+1-n)+n;
printf("%d\n",k);
}
}

-----------------------------------
srand((unsigned)time(NULL)); 随机种子,避免重复。

rand()%(m+1-n)+n; 求 n 到 m 内的随机数。

我怕你电脑承受不起这种运算。。。虽然楼上的程序很妙

#include <stdio.h>
void main()
{
float count=1;
int i=36;
while(true)
{
count*=i;
i--;
if(i==29)
{
count*=36;
break;
}
}
printf("%.0f",count);
}