#include?<string.h>
const?int?MAXSIZE?=?10;
const?int?MAXLEN?=?50;
void?mysort(char?s[][MAXLEN],int?n)?{
int?i,j,k;
char?tmp[MAXLEN];
for(i?=?0;?i?<?n;?++i)?{
k?=?i;
for(j?=?i?+?1;?j?<?n;?++j)?{
if(strcmp(s[k],s[j])?>?0)?k?=?j;
}
if(i?!=?k)?{
strcpy(tmp,s[i]);
strcpy(s[i],s[k]);
strcpy(s[k],tmp);
}
}
}
int?main()?{
int?i;
char?s[MAXSIZE][MAXLEN];
printf("輸入%d個字符串:\n",MAXSIZE);
for(i?=?0;?i?<?MAXSIZE;?++i)
fgets(s[i],MAXLEN,stdin);
printf("排序前:\n");
for(i?=?0;?i?<?MAXSIZE;?++i)
printf("%s",s[i]);
mysort(s,MAXSIZE);
printf("排序後:\n");
for(i?=?0;?i?<?MAXSIZE;?++i)
printf("%s",s[i]);
return?0;
}