Wednesday, January 22, 2014

UVa 494 - Kindergarten Counting Game solution

Problem link :  UVa 494 - Kindergarten Counting Game

Solution :


#include<bits/stdc++.h>
using namespace std;

int main()
{
    char a[10005];
    int i,l,cnt;
    while(gets(a))
    {
        l=strlen(a); cnt=0;
        for(i=0;i<l;i++)
        {
            if(isalpha(a[i]) && !isalpha(a[i+1])) cnt++;
        }
        printf("%d\n",cnt);
    }
    return 0;
}
 




No comments:

Post a Comment