UVa 494 - Kindergarten Counting Game
2014-04-19 13:57
477 查看
13518357 | 494 | Kindergarten Counting Game | Accepted | ANSI C | 0.009 | 2014-04-19 13:48:16 |
输出每行单词(只含大小写字母的字符串)数。
【解决过程】
代码如下:
#include<stdio.h> #include<string.h> #include<ctype.h> #define MAXN 5000 int main(){ char s[MAXN]; while(fgets(s,MAXN,stdin)){ int i,f=0,sum=0; for(i=0;i<strlen(s);i++){ if(isalpha(s[i])&&f==0) f=1; if(!isalpha(s[i])&&f==1){sum++;f=0;} } printf("%d\n",sum); } return 0; }
【教训】
1、不要生疏语法
2、别想抄书
相关文章推荐
- 1.10055 - Hashmat the brave warrior
- 2.10071 - Back to High School Physics
- 3.458 - The Decoder
- 4.694 - The Collatz Sequence
- 6.494 - Kindergarten Counting Game
- 7.490 - Rotating Sentences
- 8.414 - Machined Surfaces
- 9.488 - Triangle Wave
- A.457 - Linear Cellular Automata
- B.489 - Hangman Judge
- C.445 - Marvelous Mazes
- 1.10494 - If We Were a Child Again
- 2.424 - Integer Inquiry
- 3.10250 - The Other Two Trees
- 5.465 - Overflow
- 6.113 - Power of Cryptography
- 7.10161 - Ant on a Chessboard
- 8.621 - Secret Research
- 9.401 - Palindromes
- A.537 - Artificial Intelligence?