编程介的小学生 2017-09-18 03:11 采纳率: 20.5%
浏览 583
已采纳

Haiku Review

Haiku is an ancient form of Japanese poetry. A haiku is a three-line poem with seventeen syllables, where the first line must contain five syllables, the second line must contain seven syllables, and the third line must contain five syllables. The lines do not have to rhyme. Here is an example, where slashes separate the lines:
Computer programs/The bugs try to eat my code/I must not let them.

You must write a program that will review a haiku and check that each line contains the correct number of syllables.

Input

The input contains one or more lines, each of which contains a single haiku. A haiku will contain at least three words, and words will be separated by either a single space or a slash (/'). Slashes also separate the three lines of a haiku, so each haiku will contain exactly two slashes. (The three lines of the haiku will be contained within one physical line of the file.) A haiku will contain only lowercase letters (a'-z'), forward slashes (/'), and spaces, and will be no more than 200 characters long (not counting the end-of-line characters).

The haiku `e/o/i' signals the end of the input.

Each haiku is guaranteed to contain three lines, and each line will contain at least one word. Your job is to determine whether each line has the correct number of syllables (5/7/5). For the purposes of this problem, every contiguous sequence of one or more vowels counts as one syllable, where the vowels are a, e, i, o, u, and y. Every word will contain at least one syllable. (Note that this method of counting syllables does not always agree with English conventions. In the second example below, your program must consider the word code' to have two syllables because theo' and the e' are not consecutive. However, in English thee' is silent and so `code' actually has only one syllable.)

Output

For each haiku, output a single line that contains 1' if the first line has the wrong number of syllables,2' if the second line has the wrong number of syllables, 3' if the third line has the wrong number of syllables, orY' if all three lines have the correct number of syllables. If the haiku is not correct, you must output the number of the first line that has the wrong number of syllables.

Sample Input

happy purple frog/eating bugs in the marshes/get indigestion
computer programs/the bugs try to eat my code/i will not let them
a e i o u/this is seven syllables/a e i o u y
e/o/i

Sample Output

Y
2
3

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-02 15:46
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求码,CNN+LSTM实现单通道脑电信号EEG的睡眠分期评估
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路