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 ...
随机推荐
- 数据类型之Integer与int
数据类型之Integer与int Java入门 基本数据类型 众所周知,Java是面向对象的语言,一切皆对象.但是为了兼容人类根深蒂固的数据处理习惯,加快常规数据的处理速度,提供了9种基本数据类型, ...
- python 获取大乐透中奖结果
实现思路: 1.通过urllib库爬取http://zx.500.com/dlt/页面,并过滤出信息 2.将自己的买的彩票的号与开奖号进行匹配,查询是否中奖 3.将中奖结果发生到自己邮箱 caipia ...
- Linux curl 命令详解
命令概要 该命令设计用于在没有用户交互的情况下工作. curl 是一个工具,用于传输来自服务器或者到服务器的数据.「向服务器传输数据或者获取来自服务器的数据」 可支持的协议有(DICT.FILE.FT ...
- 想成为顶尖 Java 程序员?请先过了下面这些技术问题。
一.数据结构与算法基础 说一下几种常见的排序算法和分别的复杂度. 用Java写一个冒泡排序算法 描述一下链式存储结构. 如何遍历一棵二叉树? 倒排一个LinkedList. 用Java写一个递归遍历目 ...
- python3学习-Queue模块
python标准库中带有一个Queue模块,顾名思义,队列.该模块也衍生出一些基本队列不具有的功能. 我们先看一下队列的方法: put 存数据 get 取数据 empty 判断队列是否为空 qsize ...
- 分享一个非常好用又好看的终端工具--Hyper (支持windows、MacOS、Linux)
分享一个非常好用又好看的终端工具--Hyper 官网地址: https://hyper.is/ 打开官网,选择对应版本安装即可:(可能网络原因,无法下载, 可以从我分享的链接下载 链接: https: ...
- ABAP 金额转换成大写
FUNCTION zzfi_change_amount.*"---------------------------------------------------------------- ...
- 防止Web攻击,做好HTTP安全标头
前言 下图是几年前一位女性在访谈会上提问Linus(Linux操作系统之父) 为什么英伟达显卡在Linux系统中兼容性这么差? Linus说他们曾经去和英伟达谈过关于显卡在Linux上兼容的问题, ...
- (二十六)c#Winform自定义控件-有确定取消的窗体(二)
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...
- java后端_百度二面
参考: https://www.nowcoder.com/discuss/215891?type=2&order=0&pos=10&page=1 1. gc 2. java l ...