[求助]红球不能产生10以内随机号码[C语言]
自己写了一个随机生成双色球号码的小程序,但是很奇怪,运行了很多次,红球全都是10以上的数字,百思不得解,求达人指点迷津
#include <stdio.h>C
#include <stdlib.h>
#include <time.h>
#define RANGE 33
#define BALLS 6
int main()
{
int numbers[RANGE];
int red[BALLS];
int a,b,c,ball,temp;
puts("L O T T O P I C K E R\n");
srand((unsigned)time(NULL));
/*initialize the array*/
for(c<0;c<RANGE;c++)
numbers[c]=0;
printf("Press Enter to pick this week's numbers:");
getchar();
/*draw the numbers*/
puts("Here they come:");
for(c=0;c<BALLS;c++)
{
/*see if a number has already been drawn*/
do
{
ball=rand()%RANGE;
}
while(numbers[ball]);
/*number drawn*/
numbers[ball]=1;
red[c]=ball+1;
}
/*Sort the red balls*/
for(a=0;a<BALLS-1;a++)
for(b=a+1;b<BALLS;b++)
if(red[a]>red[b])
{
temp=red[b];
red[b]=red[a];
red[a]=temp;
}
for(c=0;c<BALLS;c++)
printf("%2d ",red[c]);
/*add the blue ball*/
printf("+ %d",rand()%16+1);
printf("\n\nGood luck in the drawing!\n");
return(0);
}
for(c<0;c<RANGE;c++)
numbers[c]=0;
for(c<0;c<RANGE;c++)
for(c<0;c<RANGE;c++)//c<0改为c=0
numbers[c]=0;