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