2014/02/23

UVa 494 Kindergarten Counting Game

http://acm.cs.nthu.edu.tw/problem.php?pid=7073
#include<stdio.h>
#include<string.h>

int main(void){
    char string[10000];
    int i, flag, count, k;
    while(gets(string)!= NULL){
        flag = 0;
        count = 0;
        k = strlen(string);
        for(i = 0; i < k;i++){
            if(string[i]>=65 && string[i]<=90||string[i]>=97&&string[i]<=122)
                flag = 1;
            else{
                count = count + flag;
                flag = 0;
            }
        }
        count = count + flag;/*判斷最後一個字*/
        printf("%d\n", count);
    }
    return 0;
}