验证随机性的程序
#include<stdio.h>#include<stdlib.h>
#include<time.h>
#define SIZE 1000
void main()
{
int i,number[10]={0,0,0,0,0,0,0,0,0,0};
int array[SIZE];
srand((unsigned int)time(0));
for(i=0;i<1000;i++)
{
array[i]=(rand()%10+1);
}
for(i=0;i<1000;i++)
{
switch (array[i])
{
case 1:
number[1]++;
break;
case 2:
number[2]++;
break;
case 3:
number[3]++;
break;
case 4:
number[4]++;
break;
case 5:
number[5]++;
break;
case 6:
number[6]++;
break;
case 7:
number[7]++;
break;
case 8:
number[8]++;
break;
case 9:
number[9]++;
break;
case 10:
number[10]++;
break;
}
}
for(i=1;i<=10;i++)
{
printf("%d\n",number[i]);
}
}
产生1000个1到10的随机数 ,但运行结果老不对,次数相加不等于1000,而且10出现的次数每次都等于10.。。。。。。。。求各位大神指点一二