/* 字符串指针排序函数 */
void stsrt (char *strings[], int num)
{
char *temp; int top, seek;
for (top = 0; top < num-1; top++)
for (seek = top + 1; seek < num; seek++)
if (strcmp (strings[top], strings[seek]) > 0)
{
temp = strings[top];
strings[top] = strings[seek];
strings[seek] = temp;
}
}
void print(char *strings[],int num)
{
int i;
for( i=0;i<num;i++)
printf("%s\n",strings[i]);
}
int main(void)
{
int num = 4;
char *strings[] = {"abcd","bsdb","fdad","dadw"};
stsrt(strings,num);
print(strings,num);
return 0;
}
void stsrt (char *strings[], int num)
{
char *temp; int top, seek;
for (top = 0; top < num-1; top++)
for (seek = top + 1; seek < num; seek++)
if (strcmp (strings[top], strings[seek]) > 0)
{
temp = strings[top];
strings[top] = strings[seek];
strings[seek] = temp;
}
}
void print(char *strings[],int num)
{
int i;
for( i=0;i<num;i++)
printf("%s\n",strings[i]);
}
int main(void)
{
int num = 4;
char *strings[] = {"abcd","bsdb","fdad","dadw"};
stsrt(strings,num);
print(strings,num);
return 0;
}