```c #include <stdio.h> #include <string.h> // 查找次大字符串的函数 char *findstr(int n, char s[][101]) { int i, j; char *max_str = s[0]; // 初始化最大字符串 char *second_max_str = s[1]; // 初始化次大字符串 // 找到最大字符串 for (i = 1; i < n; i++) { if (strcmp(s[i], max_str) > 0) { max_str = s[i]; } } // 找到次大字符串 for (i = 0; i < n; i++) { if (strcmp(s[i], second_max_str) > 0 && strcmp(s[i], max_str) < 0) { second_max_str = s[i]; } } return second_max_str; } ``` 额外需要注意的逻辑点: 1. 比较字符串时要使用 `strcmp` 函数,确保比较的是字符串的内容而不是地址。 2. 要注意处理输入的字符串可能为空或者长度超过 100 的情况。 3. 函数返回的是指针,要确保指针指向的字符串在函数调用结束后仍然有效。 [2024-12-02 22:59:41 | AI写代码神器 | 295点数解答]