poj 3371 Flesch Reading Ease
http://poj.org/problem?id=3371
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 #define maxn 2000 6 using namespace std; 7 char s[maxn]; 8 int word=0,sen=0,syll=0; 9 bool check(char ch) 10 { 11 if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='y') 12 return true; 13 if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U'||ch=='Y') 14 return true; 15 return false; 16 } 17 int main() 18 { 19 while(cin>>s) 20 { 21 int i; 22 int wordlen=0; 23 int syl=0; 24 bool flag=false; 25 for(i=0; s[i]; i++) 26 { 27 if((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z')) 28 { 29 wordlen++; 30 if(wordlen<=3) 31 { 32 if(!((s[i+1]>='a'&&s[i+1]<='z')||(s[i+1]>='A'&&s[i+1]<='Z'))) 33 { 34 syll++; 35 syll-=syl; 36 syl=0; 37 continue; 38 } 39 } 40 if(check(s[i])) 41 { 42 if(s[i]=='e') 43 { 44 if((!((s[i+1]>='a'&&s[i+1]<='z')||(s[i+1]>='A'&&s[i+1]<='Z')))&&s[i-1]=='l') 45 { 46 syll++; 47 syl++; 48 continue; 49 } 50 else if(!((s[i+1]>='a'&&s[i+1]<='z')||(s[i+1]>='A'&&s[i+1]<='Z'))) 51 continue; 52 else if((s[i+1]=='d'||s[i+1]=='s')&&(!((s[i+2]>='a'&&s[i+2]<='z')||(s[i+2]>='A'&&s[i+2]<='Z')))) 53 { 54 continue; 55 } 56 } 57 if(!flag) 58 { 59 flag=true; 60 syll++; 61 syl++; 62 continue; 63 } 64 else 65 continue; 66 } 67 flag=false; 68 } 69 else if(s[i]==',') 70 { 71 flag=false; 72 wordlen=0; 73 syl=0; 74 word++; 75 } 76 else if(s[i]=='.'||s[i]=='?'||s[i]=='!'||s[i]==':'||s[i]==';') 77 { 78 flag=false; 79 wordlen=0; 80 word++; 81 syl=0; 82 sen++; 83 } 84 } 85 if((s[i-1]>='a'&&s[i-1]<='z')||(s[i-1]>='A'&&s[i-1]<='Z')) 86 { 87 word++; 88 } 89 } 90 printf("%.2lf\n",(206.835-1.015*word*1.0/sen-84.6*syll*1.0/word)); 91 return 0; 92 }