Deli Deli(简单的STL + 字符串)
来源:互联网 发布:卖家怎么加入爱淘宝 编辑:程序博客网 时间:2024/06/08 17:34
Deli Deli
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2249 Accepted Submission(s): 1228
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:
- If the word is in the list of irregular words replace it with the given plural.
- Else if the word ends in a consonant followed by “y”, replace “y” with “ies”.
- Else if the word ends in “o”, “s”, “ch”, “sh” or “x”, append “es” to the word.
- 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 ith line is the plural form of the ith 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<map>#include<string>#include<stdio.h>#include<iostream>using namespace std;int main(){ map<string,string> mymap; string str; string tt; int l,n; scanf("%d%d",&l,&n); while(l--) { cin>>str>>tt; mymap[str] = tt; } while(n--) { cin>>str; int len = str.size(); if(mymap.find(str)!=mymap.end())//根据键值进行查找 如果找到 那么就直接输出mymap[str]的值 { cout<<mymap[str]<<endl; continue; } if(str[len-1]=='y'&&!(str[len-2]=='a'||str[len-2]=='e'||str[len-2]=='i'||str[len-2]=='o'||str[len-2]=='u')) { str = str.replace(len-1,3,"ies");//字符串替换函数 } else if(str[len-1]=='s'||str[len-1]=='o'||str[len-1]=='x') { str +="es"; } else if(str[len-1]=='h'&&(str[len-2]=='c'||str[len-2]=='s')) str +="es"; else str +="s"; cout<<str<<endl; } return 0;}
- Deli Deli(简单的STL + 字符串)
- Deli Deli
- HDU 1804 Deli Deli
- poj 3366 Deli Deli
- hdu_1804 Deli Deli
- HDU1804 Deli Deli
- UVa 11233 - Deli Deli
- HDU 1804 Deli Deli
- BNUOJ 1010 Deli Deli
- HDU 1804:Deli Deli
- HDU_1804Deli Deli
- 【TOJ 2911】 Deli Deli【水题】
- POJ 3366 Deli Deli 可能会
- 【端午小练】HDU1804-Deli Deli
- HDU——1804 Deli Deli
- [字典树] HDU 1804 - Deli Deli
- 杭电OJ 1803 Deli Deli
- HDU 1804 Deli Deli (String)
- combogrid实现分页、动态搜索、过滤手动输入
- textarea字数限制
- 使用datatables按自定义条件筛选数据
- NoSQL简介
- EntityTypeConfiguration
- Deli Deli(简单的STL + 字符串)
- springboot 启动错误 出现Caused by: java.lang.ClassNotFoundException: ch.qos.logback.classic.Level
- 【Python】提取网页正文内容的相关模块与技术
- 格式化输出只有固定小数点后位数
- make隐含规则
- 微信公众号开发(Java) ---- 模板消息接口的使用
- BZOJ 1202: [HNOI2005]狡猾的商人 并查集
- oracle用户默认表空间
- 小程序获取用户信息