1 条题解
-
0
#include <iostream> #include <string> #include <vector> using namespace std; // 判断是否是元音 bool is_vowel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } // 统计一行中的音节数 int count_syllables(const string& line) { int count = 0; bool in_vowel = false; for (size_t i = 0; i < line.length(); ++i) { char c = line[i]; if (is_vowel(c)) { if (!in_vowel) { ++count; in_vowel = true; } } else { in_vowel = false; } } return count; } int main() { string input; while (getline(cin, input)) { if (input == "e/o/i") break; vector<string> parts; size_t prev = 0, pos = 0; // 手动分割 / while ((pos = input.find('/', prev)) != string::npos) { parts.push_back(input.substr(prev, pos - prev)); prev = pos + 1; } parts.push_back(input.substr(prev)); // 添加最后一段 int expected[3] = {5, 7, 5}; for (int i = 0; i < 3; ++i) { if (count_syllables(parts[i]) != expected[i]) { cout << (i + 1) << endl; goto next_line; } } cout << "Y" << endl; next_line:; } return 0; }
- 1
信息
- ID
- 567
- 时间
- 1000ms
- 内存
- 10MiB
- 难度
- 5
- 标签
- 递交数
- 5
- 已通过
- 1
- 上传者