您的位置:首页 > 其它

内部赛 3 D Deli Deli

2013-09-11 14:08 423 查看


Deli Deli


Time Limit: 1000MS Memory limit:
65536K


题目描述

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.


输入

The first line
of 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 of
output, 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;}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: