Flesch Reading Ease(模拟)
生活随笔
收集整理的這篇文章主要介紹了
Flesch Reading Ease(模拟)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
http://poj.org/problem?id=3371
終于遇到簡單一點(diǎn)的模擬題了。不過本人真心沒有耐心讀題目。。。
它的大致意思就是給一段合法的文章,求出這段文章的單詞數(shù),句子數(shù),音節(jié)數(shù),按照題目給出的公式帶入就出結(jié)果。
>因?yàn)檩斎胧前纯崭褡鳛樽址Y(jié)束標(biāo)志的,因此每輸入一個(gè)字符串就是一個(gè)單詞,
>句子結(jié)束的標(biāo)志是 . ? : ; !五種,每輸入一個(gè)字符串只須判斷其最后一個(gè)字符是否是?. ? : ; !的一種,若是,句子數(shù)加1.
>對(duì)于音節(jié)數(shù),單詞長度<=3的為一個(gè)音節(jié),
大于3的情況下,句子中有元音?a(A),e(E),i(I),o(O),u(U),y(Y)時(shí)音節(jié)數(shù)加1,但如果有連續(xù)的元音字母按1個(gè)算,如果單詞以 -es 或 -ed 或 -e(不包括-le)結(jié)尾,不算一個(gè)音節(jié)。
1 #include<stdio.h> 2 #include<string.h> 3 #include<iostream> 4 #include<ctype.h> 5 using namespace std; 6 7 bool check_sentences(char ch) 8 { 9 if(ch == '.' || ch == '?' || ch == ':' || ch == ';' || ch == '!') 10 return true; 11 return false; 12 } 13 14 bool check_syllables(char ch) 15 { 16 if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y' 17 || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U' || ch == 'Y') 18 return true; 19 return false; 20 21 } 22 23 int main() 24 { 25 int sentences = 0;//句子數(shù) 26 int words = 0;//單詞數(shù) 27 int syllables = 0;//音節(jié)數(shù) 28 int len,i; 29 char s[50]; 30 31 while(cin>>s) 32 { 33 len = strlen(s); 34 35 if(check_sentences(s[len-1])) 36 sentences++; 37 38 words++; 39 40 while(!isalpha(s[len-1])) 41 len--; 42 43 if(len <= 3) 44 syllables++;//單詞長度<=3時(shí),音節(jié)數(shù)加1 45 else 46 { 47 if(check_syllables(s[0])) syllables++; 48 49 for(i = 1; i < len; i++) 50 { 51 if(check_syllables(s[i]) && !check_syllables(s[i-1])) 52 syllables++; 53 } 54 //去除以 -es -ed -e(除-le)結(jié)尾的情況 55 if(!check_syllables(s[len-3]) && s[len-2] == 'e' && (s[len-1] == 's'|| s[len-1] == 'd')) 56 syllables--; 57 if(!check_syllables(s[len-2]) && s[len-1] == 'e' && s[len-2] != 'l') 58 syllables--; 59 } 60 } 61 double ans; 62 ans = 206.835-1.015*(words*1.0/sentences)-84.6*(syllables*1.0/words); 63 printf("%.2lf\n",ans); 64 return 0; 65 } View Code?
轉(zhuǎn)載于:https://www.cnblogs.com/LK1994/p/3397679.html
總結(jié)
以上是生活随笔為你收集整理的Flesch Reading Ease(模拟)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 交强险折扣规则
- 下一篇: OSCache使用指南