码迷,mamicode.com
首页 > 其他好文 > 详细

UvaOJ494 - Kindergarten Counting Game

时间:2014-08-20 18:04:02      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:style   color   os   io   strong   for   ar   art   



 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<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cctype>
//#define lll
using namespace std;
int main()
{
    #ifdef lll
    freopen("C:\\Documents and Settings\\K70\\桌面\\cin.txt","r",stdin);
    freopen("C:\\Documents and Settings\\K70\\桌面\\out.txt","w",stdout);
    #endif
    char c;
    bool ff=true;
    int  ans=0;
    while((c=getchar())!=EOF)
    {

        if(isalpha(c))
        {
            if(ff)
               {
                   ans++;
                   ff=false;
               }
        }else if(c=='\n')
        {
            printf("%d\n",ans);
            ans=0;
            ff=true;
        }else{
            ff=true;
        }
    }
    return 0;
}



 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

UvaOJ494 - Kindergarten Counting Game,布布扣,bubuko.com

UvaOJ494 - Kindergarten Counting Game

标签:style   color   os   io   strong   for   ar   art   

原文地址:http://blog.csdn.net/fljssj/article/details/38708829

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!