#include
#include
##include
#include
#include
#define MAX 6
int main( void)
{
int number[MAX] = {0};
int i,j;
srand((unsigned) time(NULL)); /*播种子*/
for(i = 0; i < MAX; i++)
{
number[i] = rand() % 33; /*产生33以内的随机整数*/
while(number[i]==0)
number[i] = rand() % 33;
//printf("%d ", number[i]);
}
while(1)
{
for(i=0;i<6;i++)
for(j=i+1;j<6;j++)
{ if(number[i]==number[j])
{
number[j]=rand() % 33;
i=-1;
}
}
if(i==6)
break;
}
for(i = 0; i < MAX; i++)
printf("%d ", number[i]);
printf("\n");
return 0;
}
程序为1-33的不重复随机数