ACM (UVa) : 494


#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
    char s [2000];

    while (gets(s)) {

        int c=0;
        int length = strlen (s);
        int i = 0;

        while ( i < length) {
            while ( !isalpha (s[i]) )
                i++;
            if ( i < length)
                c++;
            while ( isalpha (s[i]) )
                i++;
        }
        printf("%d\n",c);

    }
    return 0;
}
Advertisements

One thought on “ACM (UVa) : 494

  1. But this code may print 2 for
    “hello!world”
    which is single word (though it is meaningless)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s