UVA oj 494 Kindergarten Counting Game(简单字符串)

原创 2016年06月01日 20:13:45
Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu

 Status

Description

Download as PDF

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<cstdio>
#include<iostream>
#include<cstring>

using namespace std;
const int maxn = 1005;
char a[maxn];

int main()
{
    while(gets(a))
    {
        int len = strlen(a);
        int ans = 0;
        int i,j;
       for(i=0;i<len;i++)
       {
           int cnt = 0;
           int flag = 0;
           while((a[i] >= 'a' && a[i] <= 'z') || (a[i] >= 'A' && a[i] <= 'Z') && i < len)
           {
               i++;
               flag = 1;
           }
           if(flag)
           ans++;
       }
       printf("%d\n",ans);
    }
}

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

UVA 494 Kindergarten Counting Game

题目链接:UVA 494 Kindergarten Counting Game
  • u011439796
  • u011439796
  • 2014年07月22日 00:50
  • 349

UVA OJ:494 - Kindergarten Counting Game

#include #include #include #define maxn 1000000 int main() {     char str[maxn];     int i,co...
  • u013646775
  • u013646775
  • 2014年04月15日 15:00
  • 273

uva 494 - Kindergarten Counting Game

Everybody sit down in a circle. Ok. Listen to me carefully. ``Woooooo, you scwewy wabbit!'' Now,...
  • Frankiller
  • Frankiller
  • 2012年05月29日 17:26
  • 378

UVa 494 - Kindergarten Counting Game

13518357 494 Kindergarten Counting Game Accepted ANSI C 0.009 2014-04-19 05:48:16
  • CKSteven
  • CKSteven
  • 2014年04月19日 13:57
  • 463

uva 494 Kindergarten Counting Game

题目:统计单词个数,单词定义:连续的字母 注意:用getline读字符串 #include #include #include #include #include #include #includ...
  • surpasslll
  • surpasslll
  • 2017年05月03日 12:10
  • 71

UVA 494 - Kindergarten Counting Game

Kindergarten Counting Game  Everybody sit down in a circle. Ok. Listen to me carefully. ...
  • that163
  • that163
  • 2012年04月09日 22:13
  • 262

UVA 494 - Kindergarten Counting Game

/****************************** *题号:494 - Kindergarten Counting Game *作者:SJF *时间:2010-8-9 *结果:AC...
  • SJF0115
  • SJF0115
  • 2011年11月17日 15:11
  • 831

UVA - 494 - Kindergarten Counting Game

#include #include using namespace std; int main() { char ch; int nCount; int iFlagLastLette...
  • u014304261
  • u014304261
  • 2014年04月06日 21:30
  • 271

UVA 494—— Kindergarten Counting Game

Everybody sit down in a circle. Ok. Listen to me carefully. ``Woooooo, you scwewy wabbit!'' Now, ...
  • bingsanchun1
  • bingsanchun1
  • 2013年08月07日 19:33
  • 727

UVA - 494 Kindergarten Counting Game

Kindergarten Counting Game Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format...
  • acm_1361677193
  • acm_1361677193
  • 2016年04月22日 23:12
  • 205
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:UVA oj 494 Kindergarten Counting Game(简单字符串)
举报原因:
原因补充:

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