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
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).
Output
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<cstring>
#include<cmath>
#include<string>
#include<map>
using namespace std;
#define maxn 1010
int main()
{
char c;
int j;
char str[maxn];
int num = ;
map<string,int>mm;
while(~(c = getchar()))
{
if(num == )
{
memset(str,,sizeof(str));
mm.clear();
j = ;
}
if(!isalpha(c)&&c!='\n')//注意只要不是空格都可以将一串字符隔开成几个单词
{
str[j] = '\0';
mm[str]++;
memset(str,,sizeof(str));
j = ;
}
else if(c == '\n')
{
num = ;
str[j] = '\0';
mm[str]++;
int count = ;
for(map<string,int>::iterator it = mm.begin();it!=mm.end();it++)
{
//cout << it -> first << endl;
if(isalpha(it->first[]))
{
//cout << it -> first[0] << endl;
count += it -> second;
}
//cout << count << endl;
}
cout << count << endl;
continue;
}
else str[j++] = c;
num++;
}
return ;
}

UVA 494 Kindergarten Counting Game map的更多相关文章

  1. UVA 494 Kindergarten Counting Game

    题目大意:输入一个字字符串,输出该字符串中所包含的"word"个数,其中"word"是指连续的字母(大小写均可) 题目思路:其实这是道水题,不过我考虑的时候,太 ...

  2. 494 - Kindergarten Counting Game

     Kindergarten Counting Game  Everybody sit down in a circle. Ok. Listen to me carefully. ``Woooooo, ...

  3. uva 11401 Triangle Counting

    // uva 11401 Triangle Counting // // 题目大意: // // 求n范围内,任意选三个不同的数,能组成三角形的个数 // // 解题方法: // // 我们设三角巷的 ...

  4. UVa 1225 Digit Counting --- 水题

    UVa 1225 题目大意:把前n(n<=10000)个整数顺次写在一起,12345678910111213...,数一数0-9各出现多少字 解题思路:用一个cnt数组记录0-9这10个数字出现 ...

  5. Kindergarten Counting Game - UVa494

    欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/uva494.html 题目描述  Kin ...

  6. UVA 1640 The Counting Problem UVA1640 求[a,b]或者[b,a]区间内0~9在里面各个数的数位上出现的总次数。

    /** 题目:UVA 1640 The Counting Problem UVA1640 链接:https://vjudge.net/problem/UVA-1640 题意:求[a,b]或者[b,a] ...

  7. Uva:11401-Triangle Counting

    Triangle Counting Time limit1000 ms Description You are given n rods of length 1, 2-, n. You have to ...

  8. UVa 1640 The Counting Problem (数学,区间计数)

    题意:给定两个数m, n,求从 m 到 n 中0-9数字各出现了多少次. 析:看起来挺简单的,其实并不好做,因为有容易想乱了.主要思路应该是这样的,分区间计数,先从个位进行计,一步一步的计算过来.都从 ...

  9. uva 1594 Ducci Sequence <queue,map>

    Ducci Sequence Description   A Ducci sequence is a sequence of n-tuples of integers. Given an n-tupl ...

随机推荐

  1. Docker部署ELK 日志归集

    ELK ELK是Elasticsearch.Logstash.Kibana的缩写,使用ELK的原因是因为公司使用Spring cloud部署了多个微服务,不同的微服务有不同的日志文件,当生产上出现问题 ...

  2. 雪花算法【分布式ID问题】【刘新宇】

    分布式ID 1 方案选择 UUID UUID是通用唯一识别码(Universally Unique Identifier)的缩写,开放软件基金会(OSF)规范定义了包括网卡MAC地址.时间戳.名字空间 ...

  3. hdu 6397 Character Encoding (生成函数)

    Problem Description In computer science, a character is a letter, a digit, a punctuation mark or som ...

  4. MobaXterm:远程终端登录软件封神选手

    提到SSH.Telnet等远程终端登录,我相信很多人想到的都是PuTTY PuTTY通常用于Windows,但实际上可以多平台运行,因此不表达为"Windows下的远程终端登录" ...

  5. JavaScript的event对象

    JavaScript的event对象中 event.target指代的是:触发事件的元素 event.currentTarget指代的是:事件绑定的元素 <!DOCTYPE html> & ...

  6. Zookeeeper环境搭建(二)

    zk一般是有2n+1个节点组成的集群.在Zookeeper服务有两个角色,一个是leader,负责写服务和数据同步:剩下的是follower,提供读服务.(为什么是2n+1个节点请看paxos算法) ...

  7. Unity工程无代码化

     目的 Unity默认是将代码放入工程,这样容易带来一些问题.1. 代码和资源混合,职能之间容易互相误改.2. 当代码量膨胀到一定程度后,代码的编译时间长到无法忍受.新版的unity支持通过asmde ...

  8. 分享我的GD32F450的IAP过程

    最近一个项目使用GD32F450VI+ESP8266需要做远程升级,基本参考正点原子IAP的那一章节,但是在GD32F450上却遇到了问题,无法跳转,然后使用正点原子的开发板stm32f429,以及s ...

  9. windows如何访问wsl系统下的文件

    windows如何访问wsl系统下的文件 可以在wsl终端输入以下命令 explorer.exe . 会出现如下界面 这样就可以很方便的查看wsl的文件了

  10. 关于在taro使用wx.parse那些事

    好久不见,好久没更新博客,最近工作也比较忙,今天在使用解决富文本的时候遇到两个bug,由于第一次使用wx.parse经验不足,走了很多弯路,今天特地把自己修复bug的感想分享一下,希望能帮助更多的小伙 ...