#include<stdio.h>
#include<string.h>
void sortString(char *arr[]){
for (int i=0;i<5;i++){
for(int j=0;j<5-i-1;j++){
if(strcmp(arr[j],arr[j+1])>0) {
char *temp = arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
}
int main(){
char *name[5]={"china","america","australia","france","german"};
sortString(name);
for(int i=0;i<5;i++){
printf("%s\n",name[i]);
}
} |
|