[解题报告]Kindergarten Counting Game
2013-02-03 22:19
267 查看
题目大意
题目原文:背景
每个人都坐在一圈。还行。仔细听我说。'Woooooo,scwewywabbit!'
现在,谁可以告诉我我刚才所说的多少单词吗?
输入
输入一段文字输出
输出这段文字中包含几个单词SampleInput
MeepMeep! ItotItawaputtytat. Idid!Idid!Ididtawaputtytat. Shsssssssssh...Iamhuntingwabbits.HehHehHehHeh...
SampleOutput
2 7 10 9
算法:
一开始我是一空格来判断一个个单词,最后发现是不行的,所以换个思维不是字母为一个个单词的分割,那么问题自然就变得简单了。
代码:这里附上我的代码,你可以去
#include<stdio.h>
#include<ctype.h>
#include<string.h>
intmain(void)
{
chara[10000];
intcount,i,num,k;
while(NULL!=gets(a))
{
count=0;
num=strlen(a);
for(i=0;i<=num;i++)
{
if(isalpha(a[i]))
for(k=i+1;k<=num;k++)
if(isalpha(a[k])==0)
{
count++;
i=k;
if(isalpha(a[k])==0)break;
}
if(a[i]=='\0')break;
}
printf("%d\n",count);
}
return0;
}
相关文章推荐
- 494 - Kindergarten Counting Game
- [UvaOJ]494-Kindergarten Counting Game
- 494 - Kindergarten Counting Game
- uva 494 Kindergarten Counting Game
- HDU 4616 Game 解题报告
- 【解题报告】HDU 4616 Game - 树形dp
- codeforces 468A. 24 Game 解题报告
- Kindergarten Counting Game
- Leetcode Jump Game II 解题报告
- Kindergarten Counting Game
- UVa OJ 494-Kindergarten Counting Game
- LeetCode解题报告—— Jump Game & Merge Intervals & Permutation Sequence
- codeforces A. Flipping Game 解题报告
- UVA 494 Kindergarten Counting Game
- 解题报告_Triangle Counting UVA - 11401_数学规律
- UVA - 494 Kindergarten Counting Game
- Kindergarten Counting Game
- UVa 494 Kindergarten Counting Game (字符串处理)
- [leetcode] 294. Flip Game II 解题报告
- UVA 494 Kindergarten Counting Game 单词统计