Tuesday, February 16, 2016

UVA 494 - Kindergarten Counting Game

#include<bits/stdc++.h>
char s[10000000];
using namespace std;
int main()
{
   int cnt=0,space=0;
   while(gets(s)){
   for(int i=0; i<strlen(s); i++){
       if(ispunct(s[i])>0 || isdigit(s[i])>0)
        s[i]=' ';
   }
   for(int i=0; i<strlen(s); i++){
   if(i!=0 && isspace(s[i])>0 && isspace(s[i-1])<=0){
        cnt++;
    }
   }
   cout<<cnt<<"\n";
   cnt=0;
   }
    return 0;
}

No comments:

Post a Comment