题解 | #字符串排序#
字符串排序
https://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723
#include <stdio.h>
#include<string.h>
int main() {
unsigned int n;
scanf("%d",&n);
char a[n][101];
int i,j;char temp[101];
for(i=0;i<n;i++){
scanf("%s",a[i]);
}
for(i=n-1;i>0;i--){
for(j=0;j<n-1;j++){
if(strcmp(a[j],a[j+1])>0){
strcpy(temp,a[j]);
strcpy(a[j],a[j+1]);
strcpy(a[j+1],temp);
}
}
}
for(i=0;i<n;i++){
printf("%s\n",a[i]);
}
return 0;
}