Created
November 5, 2014 11:32
-
-
Save bojieli/42639d4783df9ccbb757 to your computer and use it in GitHub Desktop.
Word Count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int ischar(char now) { | |
return (now >= 'a' && now <= 'z' || now >= 'A' && now <= 'Z'); | |
} | |
int main() | |
{ | |
char last = 0, now = 0; | |
int count = 0; | |
while ((now = getchar()) != EOF) { | |
if (ischar(now) && !ischar(last)) | |
count++; | |
last = now; | |
} | |
printf("%d\n", count); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks a lot ! www