-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path494.c
45 lines (40 loc) · 810 Bytes
/
494.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int isLetter(char c)
{
return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z';
}
#define NO_WORD 0x0
#define IN_WORD 0x1
int main(int argc, char const *argv[])
{
char line[0xFF];
char *p;
int state;
int count;
while(fgets(line, 0xFF, stdin))
{
count = 0;
state = NO_WORD;
p = &line[0];
for(; *p; ++p)
{
if(isLetter(*p))
{
if(state == NO_WORD)
{
++count;
state = IN_WORD;
}
}
else
{
if(state == IN_WORD)
state = NO_WORD;
}
}
printf("%d\n", count);
}
return 0;
}