Shirlies
宁静专注认真的程序媛~

#include "stdio.h"

int main()
{
 int count;
 char ch;
 int ok=0;

 while((ch=getchar())!=EOF)
 {
  ok=0;
  count=0;
  while(ch!='\n')
  {
   if((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z'))
    ok=1;
   if(ok&&!((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z')))//这里不能够写成ch==' '喔,有可能是其他非字母符号隔着,如逗号,之前就因为这样WA了
   {
    count++;
    ok=0;
   }
   ch=getchar();
  }

  if(ok)
   printf("%d\n",++count);
  else
   printf("%d\n",count);
 }

 return 0;
}

posted on 2012-01-16 13:08  Shirlies  阅读(178)  评论(0编辑  收藏  举报