494 Kindergarten Counting Game

UVA- 494 – Kindergarten Counting Game

Problem link: 494 – Kindergarten Counting Game

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=435

#include<stdio.h>
#include<string.h>
int main()
{
char s[1000];
int i,count;
while(gets(s)){
if(s==EOF)
break;
else{
count = 0;
for(i=0;i<1000;i++){
if(s[i] == '\0')
break;
else if(((s[i] >='A' && s[i]<='Z') || (s[i]>='a' && s[i]<='z'))
&&((s[i+1]<'A' || s[i+1]>'Z') && (s[i+1]<'a' || s[i+1]>'z'))){
count++;
}
}
printf("%dn",count);
}
}
return 0;
}

Advertisements