Deli Deli

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

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 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

Source
HDOJ 2007 Summer Exercise(1)

问题链接:UVA11233 POJ3366 HDU1804 Deli Deli
问题简述:把英文单词转换为复数形式。
问题分析:根据规则转换计算即可。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA11233 POJ3366 HDU1804 Deli Deli */#include <iostream>
#include <map>using namespace std;int main()
{int l, n;while(cin >> l >> n) {string w, ans;map<string, string> m;for(int i = 1; i <= l; i++) {cin >> w >> ans;m[w] = ans;}for(int i = 1; i <= n; i++) {cin >> w;if(m.find(w) != m.end()) cout << m[w] << endl;else {int end = (int)w.size() - 1;if(end > 0 && w[end] == 'y' &&w[end - 1] != 'a' && w[end - 1] != 'e' && w[end - 1] != 'i' &&w[end - 1] != 'o' && w[end - 1] != 'u') {w[end] = 'i';cout << w << "es" << endl;} else if(w[end] == 'o' || w[end] == 's' || w[end] == 'x') cout << w << "es" << endl;else if(end > 0 && w[end] == 'h' && (w[end - 1] == 'c' || w[end - 1] == 's'))cout << w << "es" << endl;else cout << w << "s" << endl;}}}return 0;
}

UVA11233 POJ3366 HDU1804 Deli Deli【水题】相关推荐

  1. Deli Deli(https://acs.jxnu.edu.cn/problem/HDU1804)

    2022寒假翻译17 熟食店 1000 ms 32768 k 描述: Deli太太经营一家熟食店"Deli Deli".去年,德里太太决定扩大她的生意,建立一个网上商店.她聘请了一 ...

  2. Deli Deli(模拟,map容器)

    Problem Description Mrs. Deli is running the delicatessen store "Deli Deli". Last year Mrs ...

  3. 水题/poj 1852 Ants

    1 /* 2 PROBLEM:poj1852 3 AUTHER:Nicole 4 MEMO:水题 5 */ 6 #include<cstdio> 7 using namespace std ...

  4. HDU2673-shǎ崽(水题)

    如果不能够直接秒杀的题,就不算水题.又应证了那句话,有时候,如果在水题上卡住,那么此题对于你来说,也就不算是水题了额~~ 刚睡醒,迷迷糊糊. 题目的意思很简单,求一个最大的,再求一个最小的.几乎是什么 ...

  5. 图论刷水题记录(二)(最短路-----SPFA算法)

    继第一篇的后续,又来刷水题了,写的是SPFA算法,这个算法的复杂度比较玄学,感觉能不用就不用了,但是他的好处就是可以判断负圈. 3月26日: 1.POJ 1847 Tram 题意:在一个交通网络上有N ...

  6. 图论刷水题记录(一)(最短路-----dijkstra算法)

    最近实在不知道干些什么,感觉自己除了水题什么都不会做,算了去刷一刷图论的水题吧本来想合起来一起发,想了想太长的话以后看起来也不方便,题目所以今天晚上就先发了dij部分,由上到下由易变难. 1.POJ ...

  7. hdu 2041:超级楼梯(水题,递归)

    超级楼梯Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissio ...

  8. HDU2568 前进【水题】

    前进 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...

  9. CF Round #426 (Div. 2) The Useless Toy 思维 水题

    题目链接: http://codeforces.com/contest/834/problem/A 题目描述: 输入起始状态和结束状态和数列长度, 判断旋转方向是顺时针逆时针还是不合理 解题思路: 长 ...

最新文章

  1. iOS 测试三方 KIF 的那些事
  2. 博士毕业论文英文参考文献换行_不用写毕业论文?一年制硕士真的不是闹着玩的吗...
  3. 新疆财大计算机科学,新疆财经大学计算机科学与工程学院学生参加了多项专业赛事...
  4. 批量去除Word的向下小箭头
  5. WebGL简易教程(十五):加载gltf模型
  6. android 显示进度,progressdialog-如何在Android中显示进度对话框?
  7. 终端连接阿里云服务器出现Permission denied (publickey)解决方法
  8. 虚拟主机服务器能干嘛用,虚拟主机能拿来干什么
  9. php中的时间戳_php时间戳是什么
  10. java订单派单规则_重点解读 | 什么是派单?派单的好处有哪些?
  11. 引入超融合技术解决虚拟机性能不足问题
  12. Java开发岗位面试题归类---怎么好好的准备面试,也算是发展学习方向
  13. android新浪微博开发Sso登录
  14. cdma特有效应_CDMA原理部分考试题(含答案).doc
  15. 局域网下两个电脑的文件实时传输--python程序
  16. PCL点云处理之Gicp配准(附代码,实验结果)(九十一)
  17. 格式工厂,帮你搞定各种格式转换!
  18. 移动端h5页面不同尺寸屏幕适配方法
  19. 库存——建立的工作日历无法在创建组织界面中选择
  20. matlab[ra ca pa],CA码产生(matlab)

热门文章

  1. [短评] 技术研发向市场运营让步
  2. Arcgis javascript那些事儿(十六)——GP服务的发布与使用
  3. Zabbix自定义监控、自动报警
  4. Unity 中 Png转Texture2D再转Sprite
  5. 20 个很棒的 jQuery Mobile 教程
  6. phoneGap实际开发中的某些雷区
  7. iocp三层架构服务器模型
  8. 计算机应用基础操作演示,计算机应用基础上机操作题
  9. Android集成JPush(极光推送)
  10. 计算机网络-自顶向下方法(7th) 第二章 Review Questions 英文题目+中文答案