2013 gzhu acm
题目描述:
Word Counting
Problem Description
Each year on May the graduate students are busy writing thesis, and the graduation thesis needs thousands of words. It's not a simple matter. Counting the words correctly become an interesting job.
We all know that the thesis may include English words, numbers, punctuation marks, images, formulas, and so on.
During the word count, we assume that English words, a string of meaningful numbers and punctuation mark is valid statistics word.
The single character in English words or numbers can not be counted as a word.
For example, the word "acm" count as one word instead of three words, number "2011" counted as a word. Of course, such space and carriage returns(Enter) can't be considered a word.
Write a program to help graduates to test whether the number of words under the thesis requirement.
Input
There are multiple test case in input, each test case end with a single line "###", the input may contain english character, numbers, punctuation e.g. ':' , ',' , '+' , '-', and space, Enter.
Output
Output the number of word for each test case, and a separate line for each case.
Sample Input
A simple test
###
Hunan University 2011 the 7th Programming Contest.
###
The 5th Central South China Programming Contest.
###
Sample Output
3
8
8
Source
这个题目要注意的是,单个的标点符号算作一个单词。
A simple+-.ui test. 答案是:8 (simple+-.ui:simple + - . ui 共5个)
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctype.h>
using namespace std; const int maxn = + ;
char s[maxn]; int main()
{
int i, len, cnt = ;
while (scanf("%s", s) != EOF)
{
if (strcmp(s, "###") == )
{
printf("%d\n", cnt);
cnt = ;
}
else{
len = strlen(s);
bool mark = false;
for (i = ; i < len; i++)
{
if (ispunct(s[i]))
{
cnt++;
mark = false;
}
else if (!mark)
{
cnt++;
mark = true;
}
}
}
}
return ;
}
2013 gzhu acm的更多相关文章
- [2013山东ACM]省赛 The number of steps (可能DP,数学期望)
The number of steps nid=24#time" style="padding-bottom:0px; margin:0px; padding-left:0px; ...
- 2013年ACM湖南省赛总结
今年的比赛最大的变化就是改用OJ判题了,相比于PC^2确实省事了不少,至少可以直接复制样例了.题目方面依旧是刘汝佳命题,这点还是相当好的,至少给人以足够的安全感. 开始比赛之后安叔瞬间就把前半部分题目 ...
- 2013年 ACM 有为杯 Problem I (DAG)
有为杯 Problem I DAG 有向无环图 A direct acylic graph(DAG),is a directed graph with no directed cycles . T ...
- 2013 gzhu 校赛
题目描述: Integer in C++ Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Othe ...
- 2013 Asia acm Hangzhou Regional Contest 杭州现场赛
B Stealing Harry Potter's Precious 题目大意:给定一个n*m的地图,某些点可以走,某些点可以走某些点不可以走,给定一个起点,又给出了k个点k<=4,要求从起点 ...
- 【HDU 2013 猴子吃桃子】 尾递归与迭代
大一时的一道C语言练习题,可作为递归和尾递归转迭代的范例.HDU 2013 http://acm.hdu.edu.cn/showproblem.php?pid=2013 题意:猴子摘了sum个桃子,从 ...
- BZOJ2831(小强的金字塔系列问题--区域整点数求法)
题目:2831: 小强的金字塔 题意就是给出A,B,C,R,L,然后求 这里其实用到扩展欧几里德.(基本上参照clj的解题报告才理解的) 分析:我们先来分析一般情况: 这里我们假设A<C和B&l ...
- Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)
Alice and Bob Time Limit: 1000ms Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...
- hduoj 4710 Balls Rearrangement 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4710 Balls Rearrangement Time Limit: 6000/3000 MS (Java/Ot ...
随机推荐
- HttpClient的Post请求数据
最近在项目中需要添加Post请求数据,以前的Get请求是使用JDK自带的URLConnection.在项目组人员的推荐下,开始使用HttpClient. HttpClient简介: HttpClien ...
- 【hibernate】Hibernate中get()和load()的区别
Hibernate中根据Id单条查询获取对象的方式有两种,分别是get()和load(),来看一下这两种方式的区别. 1. get() 使用get()来根据ID进行单条查询: 1 User user= ...
- 【js】小数点后保留两位小数
小数点后保留两位小数 dicountPrice.toFixed(2)
- iOS -- 设置label的自适应
- (void)AutoLabel { //准备工作 self.font = [UIFont systemFontOfSize:]; self.textColor = [UIColor whiteCo ...
- 017.View与窗口:AttachInfo
每一个View都需要依赖于窗口来显示,而View和窗口的关系则是放在View.AttachInfo中,关于View.AttachInfo的文章少,因为这个是View的内部类而且不是公共的,在应用层用的 ...
- linux删除空行操作:awk、grep、tr、sed
如下:如何删除空行 shen\nshen\\n sen seh sehe she she 真正删除空行,可以使用vim: 通过命令模式删除空行.vim在命令模式下(在vim里输入英文字符:进入命令模式 ...
- Service 层实现
一.实验介绍 1.1 实验内容 本节课程主要利用 Spring 框架实现 Service 层. 1.2 实验知识点 Spring 框架 1.3 实验环境 JDK1.8 Eclipse JavaEE 二 ...
- 转: 写给想成为前端工程师的同学们 (from 360前端团队)
转自: http://www.75team.com/post/to-be-a-good-frontend-engineer.html 前端工程师是做什么的? 前端工程师是互联网时代软件产品研发 ...
- Balanced Binary Tree——数是否是平衡,即任意节点左右字数高度差不超过1
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary ...
- django(一)--- 安装django
准备好虚拟环境:Python开发虚拟环境 安装前的准备 1. 下载django:django下载 本文使用的是django-1.5.9(不同版本号之间的差别还是比較大的.别搞错了) 2.准备djang ...