There are several issues in the code provided. Here is the corrected version: ```c #include <stdio.h> #include <string.h> void sort(char *p); int main(void) { char str[21]; fgets(str, 21, stdin); sort(str); printf("%s\n", str); return 0; } void sort(char *p) { int i, len = strlen(p), ln = len - 2, j; char q[20]; strncpy(q, p + 1, len - 2); for (i = 0; i < len - 3; i++) { for (j = 0; j < ln - 1; j++) { if (*(q + j) < *(q + j + 1)) { char t = *(q + j); *(q + j) = *(q + j + 1); *(q + j + 1) = t; } ln--; } } strncpy(p + 1, q, len - 2); } ``` Changes made: 1. Used `fgets` instead of `gets` to prevent buffer overflow. 2. Included `<string.h>` header for `strlen` function. 3. Fixed the usage of pointers and arrays within the `sort` function. 4. Changed `puts` to `printf` for outputting the sorted string. [2024-12-06 09:27:31 | AI写代码神器 | 664点数解答]