UVA 494 Kindergarten Counting Game map
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的更多相关文章
- UVA 494 Kindergarten Counting Game
题目大意:输入一个字字符串,输出该字符串中所包含的"word"个数,其中"word"是指连续的字母(大小写均可) 题目思路:其实这是道水题,不过我考虑的时候,太 ...
- 494 - Kindergarten Counting Game
Kindergarten Counting Game Everybody sit down in a circle. Ok. Listen to me carefully. ``Woooooo, ...
- uva 11401 Triangle Counting
// uva 11401 Triangle Counting // // 题目大意: // // 求n范围内,任意选三个不同的数,能组成三角形的个数 // // 解题方法: // // 我们设三角巷的 ...
- UVa 1225 Digit Counting --- 水题
UVa 1225 题目大意:把前n(n<=10000)个整数顺次写在一起,12345678910111213...,数一数0-9各出现多少字 解题思路:用一个cnt数组记录0-9这10个数字出现 ...
- Kindergarten Counting Game - UVa494
欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/uva494.html 题目描述 Kin ...
- 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] ...
- Uva:11401-Triangle Counting
Triangle Counting Time limit1000 ms Description You are given n rods of length 1, 2-, n. You have to ...
- UVa 1640 The Counting Problem (数学,区间计数)
题意:给定两个数m, n,求从 m 到 n 中0-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 ...
随机推荐
- golang-http 请求---设置header与直接发
背景 现在各种软件到处都是,写代码难免有时候需要http 调用其他的接口. 其实这个东西还挺常用,虽然很简单,但是写的时候 又忘,就像是提笔忘字,索性总结一下吧. 不需要设置header属性的http ...
- Wpf窗口设置屏幕居中最前显示
public Window() { InitializeComponent(); WindowStartupLocation = Win ...
- 7.源码分析---SOFARPC是如何实现故障剔除的?
我在服务端引用那篇文章里面分析到,服务端在引用的时候会去获取服务端可用的服务,并进行心跳,维护一个可用的集合. 所以我们从客户端初始化这部分说起. 服务连接的维护 客户端初始化的时候会调用cluste ...
- spring cloud stream 经验总结
---恢复内容开始--- 基本概念 spring: cloud: stream: kafka: binder: brokers: cloudTest:19092 zk-nodes: cloudTest ...
- java实现发短信功能---腾讯云短信
目录 java实现发短信功能 前言 开发环境 腾讯云 ---短信 代码 效果 结束语 java实现发短信功能 前言 如今发短信功能已经成为互联网公司的标配,本篇文章将一步步实现java发送短信 考察了 ...
- MySQL储存过程详解
我们常用的操作数据库语言SQL语句在执行的时候需要要先编译,然后执行,而存储过程(Stored Procedure)是一组为了完成特定功能的SQL语句集,经编译后存储在数据库中,用户通过指定存储过程的 ...
- [原创实践]redhat linux 5.3搭建Nexus
1:下载安装JDK,配置好环境变量(JAVA_HOME等) 下载linux下64位的jdk-7u45-linux-x64.tar.gz(百度网盘下载,官网的jdk-7u51-linux-x64.tar ...
- 天天都用消息队列,却不知道为啥要用MQ,这就有点尴尬了
1.为什么要使用消息队列? 分析:一个用消息队列的人,不知道为啥用,有点尴尬.没有复习这点,很容易被问蒙,然后就开始胡扯了. 回答:这个问题,咱只答三个最主要的应用场景(不可否认还有其他的,但是只答三 ...
- 欢迎加入我的知识星球:C语言解惑课堂
我在知识星球上开通了一个有关C语言基础答疑解惑的星球,它叫做:“C语言解惑课堂”.看这名字你就知道虽然有点俗,俗才贴近你的真正需求嘛!这是一个专门帮助C语言初学者答疑解惑的课堂.嗯~~~,关于这个星球 ...
- React SPA 应用 hash 路由如何使用锚点
当我们在做 SPA 应用的时候,为了兼容老的浏览器(如IE9)我们不得不放弃 HTML5 browser history api 而只能采用 hash 路由的这种形式来实现前端路由,但是因为 hash ...