#include <stdio.h> #define MAXLINE 10 int getline(char line[],int maxline); void copy(char to[],char from[]); int main() { int len; int max; char line[MAXLINE] = {0}; char longest[MAXLINE] = {0}; max = 0; while((len = getline(line,MAXLINE)) > 0) if(len > max) { max = len; copy(longest,line); } if(max > 0) printf("%d %s ",max,longest); return 0; } int getline(char s[],int lim) { int c,i; for(i = 0; (c=getchar()) != EOF && c != ' ';i++) { if(i < lim-2) s[i] = c; } if(c == ' ') { if(i >= lim-2) { s[lim-2] = ' '; s[lim-1] = ' '; } } return i; } void copy(char to[],char from[]) { int i = 0; while((to[i] = from[i]) != ' ') i++; } 比较蛋疼!统计总的字符数,打印能打印的最多字符。