POJ 3366//基本的字符串处理!
来源:互联网 发布:js混淆解密 编辑:程序博客网 时间:2024/05/01 00:36
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 7rice ricespaghetti spaghettioctopus octopiricelobsterspaghettistrawberryoctopuspeachturkey
Sample Output
ricelobstersspaghettistrawberriesoctopipeachesturkeys
Source
[Submit] [Go Back] [Status] [Discuss]
Home Page Go Back To top
/*题意:把单词的单数变成复数,规则是:特殊的给出来直接输出就行,不规则变化按照所说的规则变化就是简单的字符串处理*/#include <iostream>#include<string>using namespace std;struct { string m; string n;} node[100];int main() { int a,b,i,flag; string m[100],line; string::size_type len; cin >> a>> b; for(i=0; i<a; i++) cin >> node[i].m >> node[i].n; while(b--) { flag=0; cin>> line ; for(i=0; i<a; i++) if(node[i].m==line) { flag=1; cout<< node[i].n << endl; } if(!flag) { len=line.size(); if(line[len-1]=='x'||line[len-1]=='o'||line[len-1]=='s') line=line+"es"; else if(line[len-1]=='y'&&line[len-2]!='a'&&line[len-2]!='e'&&line[len-2]!='i'&&line[len-2]!='o'&&line[len-2]!='u') { line[len-1]='i'; line=line+"es"; } else if(line[len-1]=='h') { if(line[len-2]=='s'||line[len-2]=='c') line=line+"es"; } else line=line+"s"; cout << line << endl; } } return 0;}
- POJ 3366//基本的字符串处理!
- POJ 2503 二分 还有一些基本字符串的处理
- 基本的字符串处理
- poj 2895-字符串的处理
- Bash中基本的字符串处理
- uva 401 Palindromes(基本的字符串处理)
- shell处理字符串的基本命令
- java基本字符串处理
- Java基本,字符串处理
- 字符串基本处理算法
- 字符串基本处理函数
- python字符串基本处理
- POJ 1575 (字符串处理)
- poj 1035 字符串处理
- ObjectiveC开发教程--字符串的基本操作处理方法
- shell基本字符串处理2
- poj 1047 Round and Round We Go 字符串的处理
- poj 1002 方便记忆的电话号码 字符串处理+排序
- UVa 100 简单模拟
- Oracle RAC Past Image(PI) 说明
- UVa 602 简单模拟
- 物是人非的伤感个性日志:现实搁浅了我,但搁浅不了回忆
- 【Model1 / Model2】
- POJ 3366//基本的字符串处理!
- 使用RDLC报表(1) -(4)
- bind -boost
- 变得坚强,只因你不在:伤感日志
- zoj 1902
- 输出二位数组位置的用法--java
- C#双缓冲绘图
- java连接各种数据库
- poj 1089 Intervals 简单贪心