http://poj.org/problem?id=3371
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define maxn 2000
using namespace std;
char s[maxn];
int word=,sen=,syll=;
bool check(char ch)
{
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='y')
return true;
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U'||ch=='Y')
return true;
return false;
}
int main()
{
while(cin>>s)
{
int i;
int wordlen=;
int syl=;
bool flag=false;
for(i=; s[i]; i++)
{
if((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z'))
{
wordlen++;
if(wordlen<=)
{
if(!((s[i+]>='a'&&s[i+]<='z')||(s[i+]>='A'&&s[i+]<='Z')))
{
syll++;
syll-=syl;
syl=;
continue;
}
}
if(check(s[i]))
{
if(s[i]=='e')
{
if((!((s[i+]>='a'&&s[i+]<='z')||(s[i+]>='A'&&s[i+]<='Z')))&&s[i-]=='l')
{
syll++;
syl++;
continue;
}
else if(!((s[i+]>='a'&&s[i+]<='z')||(s[i+]>='A'&&s[i+]<='Z')))
continue;
else if((s[i+]=='d'||s[i+]=='s')&&(!((s[i+]>='a'&&s[i+]<='z')||(s[i+]>='A'&&s[i+]<='Z'))))
{
continue;
}
}
if(!flag)
{
flag=true;
syll++;
syl++;
continue;
}
else
continue;
}
flag=false;
}
else if(s[i]==',')
{
flag=false;
wordlen=;
syl=;
word++;
}
else if(s[i]=='.'||s[i]=='?'||s[i]=='!'||s[i]==':'||s[i]==';')
{
flag=false;
wordlen=;
word++;
syl=;
sen++;
}
}
if((s[i-]>='a'&&s[i-]<='z')||(s[i-]>='A'&&s[i-]<='Z'))
{
word++;
}
}
printf("%.2lf\n",(206.835-1.015*word*1.0/sen-84.6*syll*1.0/word));
return ;
}