Kindergarten Counting Game

原创 2013年12月04日 20:40:21

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>
int main()
{
    int a, x, i, j, k;
    char s[10000];
    while(gets(s))
    {
        x = 0;
        a = 0;
        k = strlen(s);
        for(i = 0; i <= k - 1; i++)
        {
            if(((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z')) && x == 0)
                {
                    a++;
                    x = 1;
                }
                else if(!((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z')))
                {
                    x = 0;
                }

        }
        printf("%d\n", a);
    }
    return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

UVA 494 Kindergarten Counting Game 单词统计

原题: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem...

UVa494 - Kindergarten Counting Game,java写的

我用java写的,在我的电脑中能运行

ACdream1008:A Very Easy Triangle Counting Game

Problem Description Speedcell and Shoutmon love triangles very much.One day,they are playing a ga...

群赛11.10 A Very Easy Triangle Counting Game

Problem G: A Very Easy Triangle Counting Game Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 80  ...

KinderGarten(备用资料)

  • 2010年01月21日 12:31
  • 1.59MB
  • 下载

poj 3692 Kindergarten(最大独立点集 + 二分图最大匹配)

http://poj.org/problem?id=3692 题意:在幼儿园中,有许多小孩。其中有男孩,也有女孩。女孩之间相互认识,男孩之间也相互认识。同时,一些男孩和女孩之间也相互认识,有一天,老师...

HDU 2458Kindergarten(二分图 最大团点数)

Kindergarten Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T...

POJ 3692Kindergarten(二分图最大匹配之最小顶点匹配)

题目地址:

POJ 3692 Kindergarten(最大独立集)

POJ 3692 Kindergarten(最大独立集) http://poj.org/problem?id=3692 题意:        已知班级有g个女孩和b个男孩,所有女生之间都相互认识,所有...

Poj 3692 Kindergarten【最大团】

Kindergarten Time Limit: 2000MS   Memory Limit: 65536K Total Submissions...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Kindergarten Counting Game
举报原因:
原因补充:

(最多只允许输入30个字)