#包含?& ltstdlib.h & gt
#包含?& ltstring.h & gt
int?main()?//主函數?
{
int?I,j,m,k;
char*?a[40];
夏爾?temp[10]= { " abcdefghi " };
srand(time(NULL));
for(j = 0;j & lt40;j++)
{
a[j]=(char *)malloc(sizeof(char)* 10);
m = 4+rand()%(10-4);
for(I = 0;我& ltm;i++)
{
temp[I]= ' a '+rand()% 26;
}
temp[I]= ' \ 0 ';
strcpy(a[j],temp);
printf("%s\n ",a[j]);
}
for(I = 0;我& lt39;i++)
{
for(j = I;j & lt40;j++)
{
if(strcmp(a[i],a[j])& gt;0)
{
strcpy(temp,a[I]);
strcpy(a[i],a[j]);
strcpy(a[j],temp);
}
}
}
Printf("這40個詞按字典排序的輸出是:\ n ");
for(I = 0;我& lt40;i++)
{
printf("%s\n ",a[I]);
}
}