poj 1566 Haiku Review

Haiku Review

Time Limit: 1000MS
Memory Limit: 10000K

Total Submissions: 647
Accepted: 393

Description

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<iostream>
  2: using namespace std;
  3: char sentense[210];
  4: int main()
  5: {
  6: 	int line1,line2,line3;
  7: //	freopen("E:\\c++\\oj\\t.txt","rt",stdin);
  8: 	while(1)
  9: 	{
 10: 		memset(sentense,'\0',sizeof(char)*210);	
 11: 		cin.getline(sentense,210,'\n');
 12: 		if(strcmp(sentense,"e/o/i")==0)
 13: 			break;
 14: 		line3=strlen(sentense);
 15: 		for(int i=0;i<line3;i++)
 16: 		{
 17: 			if(sentense[i]=='/')
 18: 			{
 19: 				line1=i;
 20: 				break;
 21: 			}
 22: 		}
 23: 		for(int i=line1+1;i<line3;i++)	
 24: 		{
 25: 			if(sentense[i]=='/')
 26: 			{
 27: 				line2=i;
 28: 				break;	
 29: 			}
 30: 		}	
 31: 		int count1=0;
 32: 		int vo_flag=0;
 33: 		for(int i=0;i<line1;i++)
 34: 		{
 35: 			if(sentense[i]=='a'||sentense[i]=='e'||
 36: 				sentense[i]=='i'||sentense[i]=='o'||
 37: 				sentense[i]=='u'||sentense[i]=='y')
 38: 			{
 39: 				if(vo_flag==0)
 40: 				{
 41: 					count1++;
 42: 					vo_flag=1;
 43: 				}
 44: 			}
 45: 			else
 46: 			{
 47: 				vo_flag=0;
 48: 			}
 49: 		}
 50: 		if(count1!=5)
 51: 		{
 52: 			cout<<"1"<<endl;
 53: 			continue;
 54: 		}
 55: 		int count2=0;
 56: 		int vo_flag2=0;
 57: 		for(int i=line1;i<line2;i++)
 58: 		{
 59: 			if(sentense[i]=='a'||sentense[i]=='e'||
 60: 				sentense[i]=='i'||sentense[i]=='o'||
 61: 				sentense[i]=='u'||sentense[i]=='y')
 62: 			{
 63: 				if(vo_flag2==0)
 64: 				{
 65: 					count2++;
 66: 					vo_flag2=1;
 67: 				}
 68: 			}
 69: 			else
 70: 			{
 71: 				vo_flag2=0;
 72: 			}
 73: 		}
 74: 		if(count2!=7)
 75: 		{
 76: 			cout<<"2"<<endl;
 77: 			continue;
 78: 		}
 79: 		int count3=0;
 80: 		int vo_flag3=0;
 81: 		for(int i=line2;i<line3;i++)
 82: 		{
 83: 			if(sentense[i]=='a'||sentense[i]=='e'||
 84: 				sentense[i]=='i'||sentense[i]=='o'||
 85: 				sentense[i]=='u'||sentense[i]=='y')
 86: 			{
 87: 				if(vo_flag3==0)
 88: 				{
 89: 					count3++;
 90: 					vo_flag3=1;
 91: 				}
 92: 			}
 93: 			else
 94: 			{
 95: 				vo_flag3=0;
 96: 			}
 97: 		}
 98: 		if(count3!=5)
 99: 		{
100: 			cout<<"3"<<endl;
101: 			continue;
102: 		}
103: 		cout<<"Y"<<endl;
104: 	}
105: 	return 0;
106: }
107: 
108: 

转载于:https://www.cnblogs.com/w0w0/archive/2011/11/21/2257650.html

基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip 【备注】 1、该资源内项目代码百分百可运行,请放心下载使用!有问题请及时沟通交流。 2、适用人群:计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、自动化、电子信息等)在校学生、专业老师或者企业员工下载使用。 3、用途:项目具有较高的学习借鉴价值,不仅适用于小白学习入门进阶。也可作为毕设项目、课程设计、大作业、初期项目立项演示等。 4、如果基础还行,或热爱钻研,亦可在此项目代码基础上进行修改添加,实现其他不同功能。 欢迎下载!欢迎交流学习!不清楚的可以私信问我!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值