Kindergarten Counting Game
2013-04-20 23:42
246 查看
#include <stdio.h>
#include <stdlib.h>
#define IN 1
#define OUT 0
int main()
{
char c;
int state=0,nw=0;
while((c=getchar())!=EOF)
{
switch(state)
{
case 0:if(c>='A'&&c<='Z'||c>='a'&&c<='z')
state=IN,nw++;
case 1:if(!(c>='A'&&c<='Z'||c>='a'&&c<='z'))
state=OUT;
}
if(c=='\n')
{
printf("%d\n",nw);
state=0,nw=0;
}
}
return 0;
}
这个是今天才做的,所以印象比较深刻。提交了两次才成功,因为第一次将题目意思理解错了,理解为计算一行就行了。这个题目让我对缓存输出有了比较深刻的理解。还有,我第二次把‘==’写成‘=’了,要是再犯这么低端的错误,我就剁手算了。
#include <stdlib.h>
#define IN 1
#define OUT 0
int main()
{
char c;
int state=0,nw=0;
while((c=getchar())!=EOF)
{
switch(state)
{
case 0:if(c>='A'&&c<='Z'||c>='a'&&c<='z')
state=IN,nw++;
case 1:if(!(c>='A'&&c<='Z'||c>='a'&&c<='z'))
state=OUT;
}
if(c=='\n')
{
printf("%d\n",nw);
state=0,nw=0;
}
}
return 0;
}
这个是今天才做的,所以印象比较深刻。提交了两次才成功,因为第一次将题目意思理解错了,理解为计算一行就行了。这个题目让我对缓存输出有了比较深刻的理解。还有,我第二次把‘==’写成‘=’了,要是再犯这么低端的错误,我就剁手算了。
相关文章推荐
- UVa494 - Kindergarten Counting Game-难度1
- uva 494 Kindergarten Counting Game
- UVA 494—— Kindergarten Counting Game
- UVA494 Kindergarten Counting Game【输入输出+水题】
- UVa 494 - Kindergarten Counting Game
- UVA 494-Kindergarten Counting Game
- uva494 Kindergarten Counting Game
- UVA 494―― Kindergarten Counting Game
- [UvaOJ]494-Kindergarten Counting Game
- uva494 Kindergarten Counting Game
- Volume 0. Getting Started 494 - Kindergarten Counting Game
- Kindergarten Counting Game
- UVA 494 Kindergarten Counting Game
- Kindergarten Counting Game
- Kindergarten Counting Game
- 494 - Kindergarten Counting Game
- uvaOJ 494 Kindergarten Counting Game //水题
- UVa 494 - Kindergarten Counting Game
- UVa494 Kindergarten Counting Game
- UVa 494 Kindergarten Counting Game (字符串处理)