以下是使用 C 语言解决此问题的代码: ```c #include <stdio.h> #include <string.h> // 交换函数 void swap(char *str1, char *str2) { char temp[30]; strcpy(temp, str1); strcpy(str1, str2); strcpy(str2, temp); } // 排序函数 void sort(char *s1, char *s2, char *s3) { if (strcmp(s1, s2) < 0) { swap(s1, s2); } if (strcmp(s1, s3) < 0) { swap(s1, s3); } if (strcmp(s2, s3) < 0) { swap(s2, s3); } } int main() { char s1[30], s2[30], s3[30]; printf("请输入三个字符串: "); scanf("%s%s%s", s1, s2, s3); sort(s1, s2, s3); printf("%s %s %s\n", s1, s2, s3); return 0; } ``` [2024-10-25 00:53:58 | AI写代码神器 | 290点数解答]