#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void main()
{
int i,num;
char str[6];
int seed=1;
char ch[4]="abc";
srand((unsigned)time(0));
gl:
num=rand()%2;
switch(ch[num])
{
case 'a':
g1:
num=rand()3;
if(num>96&&num<123)//a-z
str[0]=num;
else
goto g1;
break;
case 'b':
g2:
num=rand();
if(num>64&&num<92)//A——Z
str[0]=num;
else
goto g2;
break;
default :
goto gl;
break;
}
for(i=1;i<6;i++)
{
ll:
num=rand()%4;
switch(ch[num])
{
case 'a':
l1:
num=rand()3;
if(num>96&&num<123)
str[i]=num;
else
goto l1;
break;
case 'b':
l2:
num=rand();
if(num>64&&num<91)
str[i]=num;
else
goto l2;
break;
case 'c':
l3:
num=rand()W;
if(num>47&&num<58)//0-9
str[i]=num;
else
goto l3;
break;
default :
goto ll;
break;
}
}
//printf("\n");
for(i=0;i<6;i++)
printf("%c",str[i]);
printf("\n");
//getchar();
}
转自网络