用c语言编写双色球程序
答案:3 悬赏:0 手机版
解决时间 2021-02-10 22:10
- 提问者网友:放下
- 2021-02-10 11:00
用c语言编写双色球程序
最佳答案
- 五星知识达人网友:三千妖杀
- 2021-02-10 12:13
#include
#include
#include
int main()
{
int red[6];
int blue;
int i,j;
int tmp;
srand( (unsigned)time(NULL) );
i = 0;
while(i<6)
{
tmp = (1.0 * rand() /RAND_MAX) * 33 + 1;
for(j=0; j {
if(red[j] == tmp)
{
break;
}
}
if(j==i)
{
red[i] = tmp;
i++;
}
}
blue = (1.0 * rand() /RAND_MAX) * 16 + 1;
for(i = 0; i<6; i++)
{
printf("%d,",red[i]);
}
printf("\n%d",blue);
return 0;
}
#include
#include
int main()
{
int red[6];
int blue;
int i,j;
int tmp;
srand( (unsigned)time(NULL) );
i = 0;
while(i<6)
{
tmp = (1.0 * rand() /RAND_MAX) * 33 + 1;
for(j=0; j {
if(red[j] == tmp)
{
break;
}
}
if(j==i)
{
red[i] = tmp;
i++;
}
}
blue = (1.0 * rand() /RAND_MAX) * 16 + 1;
for(i = 0; i<6; i++)
{
printf("%d,",red[i]);
}
printf("\n%d",blue);
return 0;
}
全部回答
- 1楼网友:怀裏藏嬌
- 2021-02-10 14:02
以前写过一个,建两个数组,然后生成随机数就行了
- 2楼网友:廢物販賣機
- 2021-02-10 13:31
#include
#include
#include
int main()
{
int red[6];
int blue;
int i,j;
int tmp;
srand( (unsigned)time(NULL) );
i = 0;
while(i<6)
{
tmp = (1.0 * rand() /RAND_MAX) * 33 + 1;
for(j=0; j {
if(red[j] == tmp)
{
break;
}
}
if(j==i)
{
red[i] = tmp;
i++;
}
}
blue = (1.0 * rand() /RAND_MAX) * 16 + 1;
for(i = 0; i<6; i++)
{
printf("%d,",red[i]);
}
printf("\n%d",blue);
return 0;
}
#include
#include
int main()
{
int red[6];
int blue;
int i,j;
int tmp;
srand( (unsigned)time(NULL) );
i = 0;
while(i<6)
{
tmp = (1.0 * rand() /RAND_MAX) * 33 + 1;
for(j=0; j {
if(red[j] == tmp)
{
break;
}
}
if(j==i)
{
red[i] = tmp;
i++;
}
}
blue = (1.0 * rand() /RAND_MAX) * 16 + 1;
for(i = 0; i<6; i++)
{
printf("%d,",red[i]);
}
printf("\n%d",blue);
return 0;
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯