#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int main(){
int value = 0;
int maxvalue = 0;
int length;
char str[80];
gets(str);
length = strlen(str);
for(int i = 0; i < length+1; i++){
if(isalpha(str[i])){
value++;
}
else{
if(value > maxvalue)
maxvalue = value;
value = 0;
}
}
printf("%d\n", maxvalue);
return 0;
}
程序直接调用库函数ctype.h,用isalpha直接判断英文字母。