UVa494 - Kindergarten Counting Game-难度1
来源:互联网 发布:淘宝怎样重新申请退款 编辑:程序博客网 时间:2024/06/05 16:26
题目链接:
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=435
Kindergarten Counting Game
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 and Output
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).
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
27109
代码:
- #include <iostream>
- #include <cstdio>
- #include <cctype>
- using namespace std;
- int main()
- {
- #ifdef LOCAL
- freopen("f:\\input.txt", "r", stdin);
- #endif LOCAL
- char buf[10000];
- while(fgets(buf, sizeof(buf), stdin))
- {
- int count = 0, flag = 1;
- for(int i = 0; buf[i] != 0 ; ++i)
- {
- if(flag && isalpha(buf[i]))
- {//当flag为1并且buf[i]是字母时,count+1
- count ++;
- flag = 0;//当碰到一次字母后把flag置为0
- }
- if(!isalpha(buf[i]))
- {
- flag = 1;//当碰到一次非字母后把falg置为1
- }
- }
- cout << count << endl;
- }
- return 0;
- }
0 0
- UVa494 - Kindergarten Counting Game-难度1
- uva494 Kindergarten Counting Game
- UVa494 Kindergarten Counting Game
- Kindergarten Counting Game - UVa494
- UVA494 Kindergarten Counting Game
- UVA494 - Kindergarten Counting Game
- 算法竞赛入门经典-前四章-UVa494 - Kindergarten Counting Game-幼儿园数数游戏-难度1
- UVa494 - Kindergarten Counting Game,java写的
- 494 - Kindergarten Counting Game
- 494 - Kindergarten Counting Game
- 494 - Kindergarten Counting Game
- 494 - Kindergarten Counting Game
- 494 - Kindergarten Counting Game
- Kindergarten Counting Game
- 494 - Kindergarten Counting Game
- 494 - Kindergarten Counting Game
- 494 - Kindergarten Counting Game
- 494 - Kindergarten Counting Game
- [原创]Android HAL实例学习-Jollen…
- [INSTALL_FAILED_MISSING_SHARED_…
- [INSTALL_FAILED_MISSING_SHARED_…
- 关于android编译模块命令mmm
- 关于android编译模块命令mmm
- UVa494 - Kindergarten Counting Game-难度1
- Linux系统下Java应用程序打包成.jar文件
- Android的编译系统(重要)
- Android的编译系统(重要)
- android获取源代码、编译、命令
- android获取源代码、编译、命令
- 看程序员是怎么喝酒的(搞笑)
- android build
- android build