ZOJ 1713 Haiku Review

Haiku Review

Time Limit: 2 Seconds       Memory Limit: 65536 KB

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 the `o' and the `e' are not consecutive. However, in English the `e' 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, or `Y' 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个
代码:
#include <stdio.h>
#include <string.h>


int main()
{
    char str[1000];
    while(gets(str))
    {
        if(strcmp(str,"e/o/i")==0)
            break;
        int a[3]={0};
        int n,i;
        n=strlen(str);
        int k=0;
        for(i=0;i<n;i++)
        {
            if((str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'||str[i]=='y')&&
               str[i+1]!='a'&&str[i+1]!='e'&&str[i+1]!='i'&&str[i+1]!='o'&&str[i+1]!='u'&&str[i+1]!='y')
                a[k]++;
                if(str[i]=='/')
                   k++;
        }
        if(a[0]==5&&a[1]==7&&a[2]==5)
        printf("Y\n");
        else if(a[0]!=5)
        printf("1\n");
        else if(a[1]!=7)
        printf("2\n");
        else if(a[2]!=5)
        printf("3\n");
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值