#include<stdio.h> #include<string.h> void str_bobble_sort(char *a[],int count) { int i = 0, j =0 ; for (i = 0; i < count - 1; i++) { for (j = 0; j < count - 1 - i; j++) { if (strcmp(a[j],a[j+1])>0) { char *tmp = a[j]; a[j] = a[j + 1]; a[j + 1] = tmp; } } } } int main() { int i = 0; char *a[] = { "hhhh","aaaa", "cccc", "bbbb", "dddd","llll" }; str_bobble_sort(a,sizeof(a)/sizeof(a[0])); for (i = 0; i < sizeof(a) / sizeof(a[0]); i++) { printf("%s\n", a[i]); } system("pause"); return 0; }