题目描述:

                   Word Counting

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Others)

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

HNU Contest 

这个题目要注意的是,单个的标点符号算作一个单词。

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的更多相关文章

  1. [2013山东ACM]省赛 The number of steps (可能DP,数学期望)

    The number of steps nid=24#time" style="padding-bottom:0px; margin:0px; padding-left:0px; ...

  2. 2013年ACM湖南省赛总结

    今年的比赛最大的变化就是改用OJ判题了,相比于PC^2确实省事了不少,至少可以直接复制样例了.题目方面依旧是刘汝佳命题,这点还是相当好的,至少给人以足够的安全感. 开始比赛之后安叔瞬间就把前半部分题目 ...

  3. 2013年 ACM 有为杯 Problem I (DAG)

    有为杯  Problem I DAG  有向无环图 A direct acylic graph(DAG),is a directed graph with no directed cycles . T ...

  4. 2013 gzhu 校赛

    题目描述: Integer in C++ Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Othe ...

  5. 2013 Asia acm Hangzhou Regional Contest 杭州现场赛

     B Stealing Harry Potter's Precious 题目大意:给定一个n*m的地图,某些点可以走,某些点可以走某些点不可以走,给定一个起点,又给出了k个点k<=4,要求从起点 ...

  6. 【HDU 2013 猴子吃桃子】 尾递归与迭代

    大一时的一道C语言练习题,可作为递归和尾递归转迭代的范例.HDU 2013 http://acm.hdu.edu.cn/showproblem.php?pid=2013 题意:猴子摘了sum个桃子,从 ...

  7. BZOJ2831(小强的金字塔系列问题--区域整点数求法)

    题目:2831: 小强的金字塔 题意就是给出A,B,C,R,L,然后求 这里其实用到扩展欧几里德.(基本上参照clj的解题报告才理解的) 分析:我们先来分析一般情况: 这里我们假设A<C和B&l ...

  8. Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)

    Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...

  9. 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 ...

随机推荐

  1. 深入理解Thread构造函数

    上一篇快速认识线程 本文参考汪文君著:Java高并发编程详解. 1.线程的命名 在构造现成的时候可以为线程起一个名字.但是我们如果不给线程起名字,那线程会有一个怎样的命名呢? 这里我们看一下Threa ...

  2. java 字符串压缩长度并解压

    package com.wy.data.emaildata.util; import org.apache.commons.io.FileUtils; import java.io.ByteArray ...

  3. HTTPS协议工作流程

    被问到了,复习一下HTTPS的工作流程 提到https,不得不提SSL SSL 1.        安全套接字(Secure Socket Layer,SSL)协议是Web浏览器与Web服务器之间安全 ...

  4. Java中泛型T和Class<T>以及Class<?>的理解(转)

    注意:class是java的关键字, 在声明Java类时使用; Class类的实例表示Java应用运行时的类(class ans enum)或接口(interface and annotation)( ...

  5. Android 沉浸式全屏

    Android 4.4 带来了沉浸式全屏体验, 在沉浸式全屏模式下, 状态栏. 虚拟按键动态隐藏, 应用可 以使用完整的屏幕空间, 按照 Google 的说法, 给用户一种 “身临其境” 的体验. A ...

  6. Intent 传递对象

    方法: 可以让这个要传递的对象所属类实现Serializable或者Parcelable接口, 然后利用onCreate函数中的Bundle参数作为载体,传递这个对象. 例如: <span st ...

  7. GO --微服务框架(一) goa

    当项目逐渐变大之后,服务增多,开发人员增加,单纯的使用go来写服务会遇到风格不统一,开发效率上的问题. 之前研究go的微服务架构go-kit最让人头疼的就是定义服务之后,还要写很多重复的框架代码,一直 ...

  8. 【android】getDimension()、getDimensionPixelOffset()和getDimensionPixelSize()区别详解

    在自定义控件中使用自定义属性时,经常需要使用java代码获取在xml中定义的尺寸,相关有以下三个函数 getDimension() getDimensionPixelOffset() getDimen ...

  9. Wish3D用户必看!模型加载失败原因汇总

    上传到Wish3D的模型加载不出来,作品显示页面漆黑一片,是什么原因? 很有可能是操作过程中的小失误,不妨从以下几点检查.还是不行的请加QQ群(Wish3D交流群3):635725654,@Wish3 ...

  10. Foundation框架 - NSException类

    NSException类 WBStudentManager.h #import <Foundation/Foundation.h> NSString* const NameInvalidE ...