Skip to content

UVa 494

Alex Wind edited this page Aug 5, 2014 · 2 revisions

Kindergarten Counting Game

from Volume 0. Getting Started

Problem

给一个字符串,计算其中有多少个单词。其中对单词的定义是,一段连续的由小写或大写字母组成的序列。

Solution

声明一个布尔值bo,记录前一个字符是否为字母。然后遍历这个字符串,如果当前字符为字母,且bofalse的话,说明这是单词中的第一个字母,记录下来即可。

Clone this wiki locally