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