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 ...
随机推荐
- maven项目引用错误 和项目结构问题
解决办法: 鼠标右键 maven ---->update prroject Configuration 然后 maven clean maven install
- 面向对象---prototype、__proto__、实例化对象三者之间的关系
1.构造函数 a.什么是构造函数? 解释:通过关键字new 创建的函数叫做构造函数 作用:用来创建一个对象 废话少说直接上代码,首先我们还是创建一个构造函数人类 然后我们在创建两个实例,一个凡尘 一个 ...
- 转载 | 一种让超大banner图片不拉伸、全屏宽、居中显示的方法
现在很多网站的Banner图片都是全屏宽度的,这样的网站看起来显得很大气.这种Banner一般都是做一张很大的图片,然后在不同分辨率下都是显示图片的中间部分.实现方法如下: <html> ...
- 使用DOM4J 对xml解析操作
参考自:https://blog.csdn.net/redarmy_chen/article/details/12969219 dom4j是一个Java的XML API,类似于jdom,用来读写XML ...
- maven的不同版本下载及环境配置
Maven不同版本下载及环境配置 Maven下载 去到官网 https://maven.apache.org/ 会发现是最新版本,但是一般下载的话,都会下载比最新的版本要低两到三个小版本的,这里就下载 ...
- JS闪电打字特效
HTML <div class="page page-thunder-to-text"> <input id="input" type=&qu ...
- 调用链系列(3):如何从零开始捕获body和header
拓展阅读:调用链系列(1):解读UAVStack中的贪吃蛇 调用链系列(2):轻调用链实现 在Java中,HTTP协议的请求/响应模型是由Servlet规范+Servlet容器(如Tomcat)实现的 ...
- 记几个 DOM 操作技巧
使用 attributes 属性遍历元素特性 // 迭代元素的每一个特性,将它们构造成 name = value 的字符串形式 function outputAttributes (element) ...
- windbg 使用与技巧
基本知识和常用命令 (1) Windbg下载地址http://msdn.microsoft.com/en-us/windows/hardware/gg463009.aspx 安装完后执行w ...
- 8.8 day29 异常处理 UDP通信
异常处理 什么是异常? 程序在运行过程中出现了不可预知的错误 并且该错误没有对应的处理机制,那么就会以异常的形式表现出来 造成的影响就是整个程序无法运行 异常的结构 1.异常的类型 ...