Skip to content

Instantly share code, notes, and snippets.

@bojieli
Created November 5, 2014 11:32
Show Gist options
  • Save bojieli/42639d4783df9ccbb757 to your computer and use it in GitHub Desktop.
Save bojieli/42639d4783df9ccbb757 to your computer and use it in GitHub Desktop.
Word Count
#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);
}
@jingning42
Copy link

thanks a lot ! www

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment