题解 | #最长&最短文本#
最长&最短文本
https://www.nowcoder.com/practice/3331d16fe07d4358858178ff5fa73e0d
#include <stdio.h> #include <string.h> int main() { char a[100][1000]; int max = 0, min = 999, i = 0; while (gets(a[i])) { // 注意 while 处理多个 case // 64 位输出请用 printf("%lld") to if (min >= strlen(a[i])) { min = strlen(a[i]); } if (max <= strlen(a[i])) { max = strlen(a[i]); } i++; //printf("%s\n", a[i-1]); } //printf("%d_%d\n",max,min); int m; for (m = 0; m < i; m++) { if (strlen(a[m]) == min) { printf("%s\n", a[m]); } } for (m = 0; m < i; m++) { if (strlen(a[m]) == max) { printf("%s\n", a[m]); } } return 0; }