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
1 #include <stdio.h> 2 #include <string.h> 3 #define maxn 1000 4 int main() 5 { 6 int i,count = 0; 7 char buf[maxn]; 8 while (fgets(buf, sizeof(buf), stdin)) 9 { 10 for (i = 0; i < strlen(buf); i++) 11 if ((buf[i + 1] < 65 || buf[i + 1] > 122) && (buf[i] <= 122 && buf[i] >= 65)) 12 count++; 13 printf("%d\n", count); 14 count = 0; 15 } 16 return 0; 17 }
报告:较易,暂无
问题:无
解决:无