c语言案例双色球
int main()
{
srand((unsigned int)time(NULL));
//双色球两种原色 红球+蓝球(6+1)红球1-33 蓝球1-16 打印双色球中奖信息
//红色球不能重复
int ball[6];
//红球
for (int i = 0; i < 6; i++)
{
ball[i] = rand() % 33 + 1;
//去重
for (int j = 0; j < i; j++)
{
if (ball[i] == ball[j])
{
i--;
continue;
}
}
}
for (int i = 0; i < 6; i++)
{
printf("%d ", ball[i]);
}
printf("+ %d\n", rand()%16+1);
}
END