计算一个英文句子中最长单词的长度(字母个数)max.,

#include<stdio.h>
main()
{ static char s[]={"you make me happy when days are grey."},*t;
int max=0,len=0;
t=s;
while(*t!='.')
{
while(((*t<='Z')&&(*t>='A'))||((*t<='z')&&(*t>='a')))
{ len++;
___(1)___;
}
if(max<len)
___(2)___;
___(3)___;
t++;
}
printf("max=%d",max);
}
填空

程序1:
#include<stdio.h> main()
{ static char s[]={"you make me happy when days are grey."},*t; int max=0,len=0; t=s;
while(*t!='.') { while(((*t<='Z')&&(*t>='A'))||((*t<='z')&&(*t>='a')))
{ len++;
t++;
}
if(max<len)
max=len;
len=0; t++; }
printf("max=%d",max); }

程序2:
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define N 100

char *maxlenword(char statement[],char maxword[]) {
int i = 0,j;
char word[N];
maxword[0] = '\0';
for(i = 0; statement[i]; i++) {
if(!isalpha(statement[i++])) continue;
--i;
j = 0;
while(statement[i] && isalpha(statement[i]))
word[j++] = statement[i++];
word[j] = '\0';
if(strlen(maxword) < strlen(word))
strcpy(maxword,word);
}
return maxword;
}

int main() {
char a[N] = {'\0'};
char b[N] = {'\0'};
printf("请输入字符串:\n");
gets(a);
maxlenword(a,b);
printf("最长单词长为:%d\n",strlen(b));
printf("最长单词为:\"%s\"\n",b);
return 0;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-05-31
1、t++;
2、max=len;
3、len=0;本回答被网友采纳