POJ 3371.Flesch Reading Ease
2018-01-28 18:51
337 查看
题目:http://poj.org/problem?id=3371
AC代码(C++):
总结: 很坑爹的题, 不建议做. 原理很简单, 就是计数, 但是我认为题目没讲清楚, 题目中给出的符号很多根本不出现, 如果出现了就很难做(比如引号什么的), 会出现的符号在程序中列出来了. 还有一个坑就是如果需要忽略的后缀前面已经有了元音字母, 注意不要重复忽略.
AC代码(C++):
#include <iostream> #include <queue> #include <set> #include <string> #include <algorithm> #include <string.h> #include <math.h> #define INF 0x3f3f3f3f #define eps 1e-8 typedef unsigned long long ULL; using namespace std; char word[1000]; int words, sents, syllas; bool isVowel(char a) { if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u' || a == 'y')return true; else return false; } int main() { words = 0; sents = 0; syllas = 0; while (cin >> word) { words++; char tmp = word[strlen(word) - 1]; if (tmp == '.' || tmp == '?' || tmp == '!' || tmp == ';' || tmp == ':')sents++; if ((tmp<'a' || tmp>'z') && (tmp<'A' || tmp>'Z'))word[strlen(word) - 1] = '\0'; if (strlen(word) <= 3) { syllas++; continue; } for (int i = 0; word[i] != '\0'; i++)if (word[i] >= 'A'&&word[i] <= 'Z')word[i] -= 'A' - 'a'; for (int i = 0; word[i] != '\0'; i++) { if (isVowel(word[i])) { if (!isVowel(word[i + 1])) { syllas++; } } } if (word[strlen(word) - 2] == 'e'&&word[strlen(word) - 1] == 's'&&!isVowel(word[strlen(word) - 3]))syllas--; else if (word[strlen(word) - 2] == 'e'&&word[strlen(word) - 1] == 'd'&&!isVowel(word[strlen(word) - 3]))syllas--; else if (word[strlen(word) - 2] != 'l'&&word[strlen(word) - 1] == 'e'&&!isVowel(word[strlen(word) - 2]))syllas--; } double ans = 206.835 - 1.015*((double)words / sents) - 84.6*((double)syllas / words); printf("%.2lf", ans); //system("pause"); }
总结: 很坑爹的题, 不建议做. 原理很简单, 就是计数, 但是我认为题目没讲清楚, 题目中给出的符号很多根本不出现, 如果出现了就很难做(比如引号什么的), 会出现的符号在程序中列出来了. 还有一个坑就是如果需要忽略的后缀前面已经有了元音字母, 注意不要重复忽略.
相关文章推荐
- 【POJ 3371】Flesch Reading Ease
- POJ 3371 Flesch Reading Ease 无聊恶心模拟题
- poj 3371 Flesch Reading Ease
- POJ 3371 Flesch Reading Ease
- POJ 3371 Flesch Reading Ease
- POJ 3371 Flesch Reading Ease 可能会
- 【POJ 3371】 Flesch Reading Ease(模拟)
- poj3371--Flesch Reading Ease(模拟)
- POJ 3371 Flesch Reading Ease
- POJ 3371 Flesch Reading Ease (模拟题)
- poj 3371 Flesch Reading Ease
- poj 3371 Flesch Reading Ease
- poj-3371-Flesch Reading Ease
- POJ3371-Flesch Reading Ease
- Flesch Reading Ease
- POJ3371-Flesch Reading Ease
- Flesch Reading Ease -POJ3371模拟
- Flesch Reading Ease -POJ3371模拟
- POJ 3371 Flesch Reading Ease
- Flesch Reading Ease 模拟