zoukankan      html  css  js  c++  java
  • 【UVA 494 Kindergarten Counting Game】

     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 // Project name : D ( Kindergarten Counting Game ) 
     2 // File name    : main.cpp
     3 // Author       : Izumu
     4 // Date & Time  : Tue Jul 10 19:40:52 2012
     5 
     6 
     7 #include <stdio.h>
     8 #include <ctype.h>
     9 #include <string.h>
    10 #define N 10000
    11 
    12 char a[N];
    13 
    14 int main()
    15 {
    16     int n;
    17     
    18     while(gets(a)!=NULL)
    19     {
    20         n=strlen(a);
    21         int found,count=0;
    22         for(int i=0;i<n;i++)
    23         {    
    24             if(isalpha(a[i])) found=1;
    25             else{
    26                 if(found) count++; 
    27                 found =0;
    28             }
    29             
    30             
    31         }
    32         printf("%d\n",count);
    33         
    34     }
    35     return 0;
    36 }
    37 
    38 
    39 // end 
    40 // ism 
  • 相关阅读:
    DHCP服务器搭建
    linux文件通配符
    NTP服务器搭建
    .Net下MoongoDB的简单调用
    Mac 下安装配置MongoDB讲解
    Redis 介绍学习
    PostgreSQL学习之路一 安装
    CentOS安装PostgreSQL
    离线安装PostgreSQL11.6
    PostgreSQL 安装扩展插件plpython3u执行python,访问页面或者第三方程序
  • 原文地址:https://www.cnblogs.com/ismdeep/p/2585191.html
Copyright © 2011-2022 走看看