#include <stdio.h> |
#include <string.h> |
char words[10][6]={ "dszcr" , "dwcrg" , "cueuz" , "nufas" , "rgvzu" , "fesiu" , "fwehs" , "dqhzo" , "woajz" , "hgruk" }; |
char * temp[10]; |
void sort(); |
void sortonce( char *strings[], int num) { |
char *temp; |
int top ,seek; |
//对字符串指针进行排序 |
for (top=0; top< num-1;top++ ) |
for (seek = top+1;seek<num;seek++) |
//对字符串进行比较strcmp |
if ( strcmp (strings[top] ,strings[seek] ) > 0) |
//交换排序 |
{ |
temp = strings[top]; |
strings[top] = strings[seek]; |
strings[seek]= temp; |
} |
} |
void sort() { |
int i,j; |
for (i=0;i<=9;i++) temp[i]=words[i]; |
sortonce(temp,10); |
} |
int main() { |
int i; |
sort(); |
for (i=0;i<=9;i++) { |
printf ( "%s," ,temp[i]); |
} |
return 0; |
} |