统计单词个数,uva的简单题,真心不知道自己哪错了,给个错误样例~
这是我代码:#include <stdio.h>
#include <string.h>
int main()
{
char a[1000000];
int count,len,i;
//freopen("in.txt","r",stdin);
while(gets(a) != NULL)
{
count=0;
len=strlen(a);
a[len+1]='\0';
for(i=0; i<=len; i++)
{
if(a[i]>='A' && a[i]<='Z')
a[i]+=32;
if((a[i]>='a' && a[i]<='z') && (a[i+1]<'a' || a[i+1]>'z'))
count++;
}
printf("%d\n",count);
}
return 0;
}
真心求解,谢~