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

题意:
输出单词的复数形式。
有些是特殊变化的,事先给你。
如果是以辅音字母加y结尾的,改y为i再加es。
如果是以”o”, “s”, “ch”, “sh” or “x”,结尾的,直接加es。
其他的直接加s。

用Map存储特殊的变化单词。再模拟处理就OK。


import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);while(sc.hasNext()){int n =sc.nextInt();int m =sc.nextInt();Map<String, String> map = new HashMap<String, String>();for(int i=0;i<n;i++){String a = sc.next();String b = sc.next();map.put(a, b);}for(int i=0;i<m;i++){String str=sc.next();if(map.get(str)!=null){System.out.println(map.get(str));}else{char a = str.charAt(str.length()-2);char b= str.charAt(str.length()-1);if(a!='a'&&a!='e'&&a!='i'&&a!='o'&&a!='u'&&str.charAt(str.length()-1)=='y'){for(int k=0;k<str.length()-1;k++){System.out.print(str.charAt(k));}System.out.println("ies");}else if((a=='c'&&b=='h')||(a=='s'&&b=='h')||b=='o'||b=='s'||b=='x'){for(int k=0;k<str.length();k++){System.out.print(str.charAt(k));}System.out.println("es");}else{for(int k=0;k<str.length();k++){System.out.print(str.charAt(k));}System.out.println("s");}}}}}
}

HDOJ/HDU 1804 Deli Deli(英语单词复数形式~)相关推荐

  1. 英语------------单词复数形式的规律

    1.名词由单数变复数的基本方法如下: ①在单数名词词尾加s.如:map → maps,boy→ boys,horse→ horses, table→ tables. ②s,o,x ,sh,ch结尾的词 ...

  2. 英语单词复数到底读s还是z?

    1.为了追求发音的顺口和协调,英语人民普遍有一个发音倾向,并且大家都在自觉地执行,就是让清辅音和清辅音连在一起(如[ps],[ts],[ks],[fs]),让响亮音和响亮音连在一起(如[bz], [d ...

  3. HDU 1804 Deli Deli

    题目链接:Click here~~ 水水的字符串处理.主要练习下map的用法. 不过这道题,让我一下就想起了初中刚学英语的时候,各种怀念啊. 题意: 输出单词的复数形式.有些是特殊变换的,它事先给你. ...

  4. HDU——1804 Deli Deli

    题意:将规则动词化为复数形式,将不规则动词化为对应的复数形式,不规则动词的复数形式给出. 解题思路:用map将不规则动词映射成一张表,详见代码. Code: #include <iostream ...

  5. UVA11233 POJ3366 HDU1804 Deli Deli【水题】

    Deli Deli Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

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

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

  7. hdu 2243 考研路茫茫——单词情结(AC自动+矩阵)

    考研路茫茫--单词情结 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  8. 计算机的复数英语怎么读,英语的复数怎么读

    目录 1.土豆的复数英语怎么读 1.英语中的月份的复数 怎么读 读音? months 最后两个辅音,是否可以省略一个. 2.在清辅音后,读/s/,如books, 在浊辅音和元音后,读/z/,如dogs ...

  9. 计算机音译英语单词,汉语谐音英文单词

    虽说英文fly看似是很简单的一个单词,但很多人都不知道它具体的几种汉语意思是什么的.以下是烟花美文网小编为大家整理了英语fly表达的汉语意思,一起来看看吧!fly的汉语意思英 [fla] 美 [fla ...

最新文章

  1. Udacity机器人软件工程师课程笔记(二十) - 感知 - 校准,过滤, 分段, RANSAC
  2. gprof使用介绍 (gcc -pg)
  3. opeansea, nft, trend
  4. CMU提出「十字绣网络」,自动决定多任务学习的最佳共享层
  5. 剑指Offer - 面试题10- I. 斐波那契数列
  6. 云享专家倪升武:微服务架构盛行的时代,你需要了解点 Spring Boot
  7. pythonbool类型数组生成_对numpy中布尔型数组的处理方法详解
  8. java 输出中文_没见过的 Java 编程入门教程!例程使用中文标识符代码:问个好吧...
  9. 【光学】基于Matlab模拟衍射光栅实验
  10. solidworks2016安装教程
  11. html表格上下居中 w3c,HTML中怎么把表格居中
  12. archlinux + dwm系统美化
  13. java endian_java – 将小Endian文件转换成大Endian
  14. java double精度丢失 0.1+0.2不等于0.3
  15. uni-app H5实现扫码登录功能
  16. linux之sed命令详解
  17. UINavigation导航栏和UITabbar布局和样式
  18. 失物招领小程序_@全体川农er:川农史上最全失物招领攻略!
  19. 浏览器渲染类型2d 3d_Google在浏览器中提供3D渲染
  20. c语言武汉市出租车收费标准 3公里以内,武汉的士/出租车起步价是多少?怎么算的?...

热门文章

  1. HTTP POST body常见的四种数据格式
  2. 1.expan扩容函数的一些理解
  3. 充满科技感的农业,是年轻人的『菜』吗?
  4. 4p营销组合策略案例_营销4P到底是什么?理解营销4P订定你的营销策略架构
  5. 隆尧县农特产品区域公用品牌“尧尧领鲜”正式发布!
  6. 怎样把扫描的图片转换成pdf
  7. 云南省中级职称计算机考试成绩查询时间,职称考试_云南招考频道_云南人事考试网_云南考试中心-云南考试网...
  8. 软件设计模式-行为型模式
  9. jetty了解与使用
  10. el-popconfirm中confirm的使用