HDU 1804:Deli Deli
来源:互联网 发布:linux c sleep 线程 编辑:程序博客网 时间:2024/06/08 04:30
Deli Deli
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1708 Accepted Submission(s): 942
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.
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 7rice ricespaghetti spaghettioctopus octopiricelobsterspaghettistrawberryoctopuspeachturkey
Sample Output
ricelobstersspaghettistrawberriesoctopipeachesturkeys
如果要延长数组的话,记得要加\0哦~~当然也可以用stract...
AC-code:
#include<cstdio>#include<cstring>#define max(a,b) a>b?a:bchar str[25];int m;struct node{char s1[25],s2[25];}s[25];int f(char ch){char *yuan="aeiou";for(int i=0;i<5;i++)if(ch==yuan[i])return 0;return 1;}void check(int l){int i;for(i=0;i<m;i++)if(!strcmp(s[i].s1,str)){printf("%s\n",s[i].s2);return ;}if(str[l-1]=='y'&&f(str[l-2])){str[l-1]='i';str[l]='e';str[l+1]='s';str[l+2]='\0';printf("%s\n",str);return;}if(str[l-1]=='o'||str[l-1]=='s'||str[l-1]=='x'){str[l]='e';str[l+1]='s';str[l+2]='\0';printf("%s\n",str);return ;}if(l>1&&(str[l-1]=='h'&&(str[l-2]=='c'||str[l-2]=='s'))){str[l]='e';str[l+1]='s';str[l+2]='\0';printf("%s\n",str);return ;}printf("%ss\n",str);return ;}int main(){int n,i,l;scanf("%d%d",&m,&n);for(i=0;i<m;i++)scanf("%s%s",s[i].s1,s[i].s2);for(i=0;i<n;i++){scanf("%s",str);l=strlen(str);check(l);}return 0;}
0 0
- HDU 1804 Deli Deli
- HDU 1804 Deli Deli
- HDU 1804:Deli Deli
- HDU——1804 Deli Deli
- [字典树] HDU 1804 - Deli Deli
- HDU 1804 Deli Deli (String)
- HDOJ/HDU 1804 Deli Deli(英语单词复数形式~)
- Deli Deli
- poj 3366 Deli Deli
- hdu_1804 Deli Deli
- HDU1804 Deli Deli
- UVa 11233 - Deli Deli
- BNUOJ 1010 Deli Deli
- HDU_1804Deli Deli
- 【TOJ 2911】 Deli Deli【水题】
- POJ 3366 Deli Deli 可能会
- 【端午小练】HDU1804-Deli Deli
- 杭电OJ 1803 Deli Deli
- getTrackbarPos函数
- 设计模式之策略模式参悟
- [LeetCode]Lowest Common Ancestor of a Binary Search Tree
- Linux下,多线程程序死循环问题调试
- Ubuntu下QT程序中编译时出现speex/speex.h: No such file or directory
- HDU 1804:Deli Deli
- PostgreSQL新手入门
- LeetCode 214. Shortest Palindrome
- Spring学习(七)spring整合mybatis
- cocos2d-x 颜色混合
- iOS Xcode工程目录的 folder 和 group的区别(蓝色和黄色文件夹的区别)
- Moving Tables(贪心或Dp POJ1083)
- Netfilter连接跟踪状态解析
- hibernte与spring结合时,配置使hibernate的session的生命周期延迟,以及配置httpsession的时间