【getline】#70 A. Haiku

A. Haiku
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Haiku is a genre of Japanese traditional poetry.

A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should contain exactly 7 syllables, and the third phrase should contain exactly 5 syllables). A haiku masterpiece contains a description of a moment in those three phrases. Every word is important in a small poem, which is why haiku are rich with symbols. Each word has a special meaning, a special role. The main principle of haiku is to say much using a few words.

To simplify the matter, in the given problem we will consider that the number of syllable in the phrase is equal to the number of vowel letters there. Only the following letters are regarded as vowel letters: "a", "e", "i", "o" and "u".

Three phases from a certain poem are given. Determine whether it is haiku or not.

Input

The input data consists of three lines. The length of each line is between 1 and 100, inclusive. The i-th line contains the i-th phrase of the poem. Each phrase consists of one or more words, which are separated by one or more spaces. A word is a non-empty sequence of lowercase Latin letters. Leading and/or trailing spaces in phrases are allowed. Every phrase has at least one non-space character. See the example for clarification.

Output

Print "YES" (without the quotes) if the poem is a haiku. Otherwise, print "NO" (also without the quotes).

Sample test(s)
input
on  codeforces 
beta round is running
   a rustling of keys 
output
YES
input
how many gallons
of edo s rain did you drink
                                cuckoo
output
NO


给三句话问这是不是俳句~

啊啦,做题目还可以学知识,妙哉妙哉~

俳句是日本的一种古典短诗,由“五-七-五”,共十七字音组成,要求严格,受“季语”的限制。

不过这里我们的题目被简化了,问三句里的元音字母是否是5/7/5的%……(嫌弃脸)

好吧,遍历一遍数数字拿分走人

这里因为每行中间是有空格的,而string的cin每次都会遇到空格结束,我们想一下读入一行怎么办呢?

getline()函数—— getline(cin,s)就是在控制台录入单行赋值给s,这里cin是可以换成fin啥的哦,因为有的时候我们还需要文件读入呢~

#include <cstdio>
#include <string>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
// http://codeforces.com/contest/78 
// Haiku

int judge(string s,int n)
{
	int cnt=7-n%2*2;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u')
		cnt--;
	}
	if(!cnt)return n;
	else return 0;
}

int main()
{
	string s;
	int flag=0; 
	for(int i=1;i<=3;i++)
	{ getline(cin,s); flag+=judge(s,i);}
	if(flag==6)cout<<"YES";else cout<<"NO";
	return 0;
} 






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

糖果天王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值