Kindergarten Counting Game 

Everybody sit down in a circle. Ok. Listen to me carefully.

``Woooooo, you scwewy wabbit!''

Now, could someone tell me how many words I just said?

 

Input and Output

Input to your program will consist of a series of lines, each line containing multiple words (at least one). A ``word'' is defined as a consecutive sequence of letters (upper and/or lower case).

 

Your program should output a word count for each line of input. Each word count should be printed on a separate line.

 

Sample Input

 

Meep Meep!
I tot I taw a putty tat.
I did! I did! I did taw a putty tat.
Shsssssssssh ... I am hunting wabbits. Heh Heh Heh Heh ...

 

Sample Output

 

2
7
10
9
#include"stdio.h"
#include"string.h"
#include"ctype.h"
int main()
{  char s[2500];
   int i,n;
   while(gets(s)!=NULL)
   {i=1;
    n=0;
    while(s[i])
    {if(isalpha(s[i-1]))//isaplpha()函数的作用是检查是否为字母; 
      if(!isalpha(s[i]))
      n++;
      i++;}
    printf("%d\n",n);
}
return 0;
} 

 

posted on 2013-02-24 00:21  LOVE小熊ing  阅读(212)  评论(0编辑  收藏  举报