Deli Deli

52 篇文章 0 订阅

Deli Deli

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1227    Accepted Submission(s): 673


Problem Description
Mrs. Deli is running the delicatessen store "Deli Deli". Last year Mrs. Deli has decided to expand her business and build up an online store. She has hired a programmer who has implemented the online store.

Recently some of her new online customers complained about the electronic bills. The programmer had forgotten to use the plural form in case that an item is purchased multiple times. Unfortunaly the programmer of Mrs. Deli is on holiday and now it is your task to implement this feature for Mrs. Deli. Here is a description how to make the plural form:

1. If the word is in the list of irregular words replace it with the given plural.
2. Else if the word ends in a consonant followed by "y", replace "y" with "ies".
3. Else if the word ends in "o", "s", "ch", "sh" or "x", append "es" to the word.
4. Else append "s" to the word.
 

Input
The first line of the input file consists of two integers L and N (0 ≤ L ≤ 20, 1 ≤ N ≤ 100). The following L lines contain the description of the irregular words and their plural form. Each line consists of two words separated by a space character, where the first word is the singular, the second word the plural form of some irregular word. After the list of irregular words, the following N lines contain one word each, which you have to make plural. You may assume that each word consists of at most 20 lowercase letters from the english alphabet ('a' to 'z').

 

Output
Print N lines of output, where the i th line is the plural form of the i th input word.

 

Sample Input
  
  
3 7 rice rice spaghetti spaghetti octopus octopi rice lobster spaghetti strawberry octopus peach turkey
 

Sample Output
  
  
rice lobsters spaghetti strawberries octopi peaches turkeys
 
#include<iostream>
using namespace std;
typedef struct infor
{
	char positive[23],negtive[23];
}infor;
infor a[23];
int n,t;
bool judge(char b[]){
	int i;
	for(i=0;i<n;i++)
		if(!strcmp(a[i].positive,b)){
			cout<<a[i].negtive<<endl;
			return true;
		}
		return false;
}
int main()
{
	while(cin>>n>>t){
		int i;
	
		for(i=0;i<n;i++)
			cin>>a[i].positive>>a[i].negtive;
		for(i=0;i<t;i++)
		{
			char ch[23];
			cin>>ch;
			int len=strlen(ch);
		
			if(!judge(ch))
			{	
				char b[3];
				b[0]=ch[len-2];
				b[1]=ch[len-1];
				b[2]='\0';
				char d[3];
				d[0]=ch[len-1];
				d[1]='\0';
				if(!strcmp(b,"ch")||!strcmp(b,"sh")){
					cout<<ch;
					cout<<"es"<<endl;
					continue;
				}
				if(!strcmp(d,"o")||!strcmp(d,"s")||!strcmp(d,"x")){
					cout<<ch;
					cout<<"es"<<endl;
					continue;
				}
				if(!strcmp(d,"y")&&ch[len-2]!='a'&&ch[len-2]!='e'&&ch[len-2]!='i'&&ch[len-2]!='o'
					&&ch[len-2]!='u'){
					ch[len-1]='\0';
					cout<<ch;
					cout<<"ies"<<endl;
					continue;
				}
				else
				{
					cout<<ch;
					cout<<"s"<<endl;
					continue;
				}
			}
			
		}
	}
	return 0;
}


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值