内部赛 3 D Deli Deli
2013-09-11 14:08
423 查看
Deli Deli
Time Limit: 1000MS Memory limit:
65536K
题目描述
Mrs. Deli isrunning 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.
输入
The first lineof the input file consists of two integers L[/b] and N[/b] (0
≤ L ≤ 20[/i], 1
≤ N ≤ 100[/i]). The following L[/b] 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[/b] 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\').
输出
Print N[/b] lines ofoutput, where the ith[/b] line is
the plural form of the ith[/b] input
word.
示例输入
示例输出
字符串的处理,注意看清题意!!!代码:#include<stdio.h>#include<stdlib.h>#include<string.h>struct node{ char a[100]; char b[100];}str[25];char str1[105];int main(){ int n,m; int i,j,k; int len; scanf("%d%d",&n,&m); for(i=0;i<n;i++) { scanf("%s%s",str[i].a,str[i].b); } for(i=0;i<m;i++) { //memset(str1,0,sizeof(str1)); scanf("%s",str1); len=strlen(str1); for(j=0;j<n;j++) { if(strcmp(str1,str[j].a)==0) { printf("%s\n",str[j].b); break; } } if(j>=n) { if(str1[len-1]=='y'&&str1[len-2]!='a'&&str1[len-2]!='e'&&str1[len-2]!='i'&&str1[len-2]!='o'&&str1[len-2]!='u')//注意这地方啊!! { for(k=0;k<len-1;k++)
printf("%c",str1[k]); printf("ies\n"); } else
if(str1[len-1]=='o'||str1[len-1]=='s'||str1[len-1]=='x'||(str1[len-1]=='h'&&(str1[len-2]=='s'||str1[len-2]=='c'))) { printf("%s",str1); printf("es\n"); } else { printf("%s",str1); printf("s\n"); } } } return 0;}
相关文章推荐
- 内部赛3 B Black and white painti…
- 内部赛3 F Frequent values
- 编译原理笔记3 编译程序
- flex 3 + .net开发flash Remoting…
- 3&nbsp;Nginx的基本配置和优化
- Maven 3 入门 -- 安装与配置
- bash shell笔记3 结构化命令二
- flex 3 + .net开发flash Remoting…
- Real Racing 3 v1.…
- java&nbsp;JDBC实验题【实验题3&nbsp;学生信…
- Java学习笔记3 原生数据类型 Primi…
- Real Racing 3 v1.…
- Maven 3 入门 -- 安装与配置
- Sublime Text 3 破…
- Real Racing 3 v1.…
- Java语法总结&nbsp;-&nbsp;内部类
- 通过 Frame来实现页面内部导航
- Real Racing 3 v1.…
- Php&nbsp;session内部执行流程的再…
- Real Racing 3 v1.…