您的位置:首页 > 其它

HDU  1075  What Are You Talking …

2012-12-05 17:13 417 查看
What Are You Talking AboutTime Limit: 10000/5000 MS(Java/Others)    Memory Limit:102400/204800 K (Java/Others)Total Submission(s): 4669   Accepted Submission(s):1401Problem DescriptionIgnatius is so lucky that he met a Martian yesterday. But hedidn't know the language the Martians use. The Martian gives him ahistory book of Mars and a dictionary when it leaves. Now Ignatiuswant to translate the history book into English. Can you helphim? InputThe problem has only one test case, the test case consists oftwo parts, the dictionary part and the book part. The dictionarypart starts with a single line contains a string "START", thisstring should be ignored, then some lines follow, each linecontains two strings, the first one is a word in English, thesecond one is the corresponding word in Martian's language. A linewith a single string "END" indicates the end of the directory part,and this string should be ignored. The book part starts with asingle line contains a string "START", this string should beignored, then an article written in Martian's language. You shouldtranslate the article into English with the dictionary. If you findthe word in the dictionary you should translate it and write thenew word into your translation, if you can't find the word in thedictionary you do not have to translate it, and just copy the oldword to your translation. Space(' '), tab('\t'), enter('\n') andall the punctuation should not be translated. A line with a singlestring "END" indicates the end of the book part, and that's alsothe end of the input. All the words are in the lowercase, and eachword will contain at most 10 characters, and each line will containat most 3000 characters. OutputIn this problem, you have to output the translation of thehistory book. Sample InputSTARTfrom fiwohello difhmars riwosfearth fnnvklike fiiwjENDSTARTdifh, i'm fiwo riwosf.i fiiwj fnnvk!END Sample Outputhello, i'm from mars.i like earth!HintHuge input, scanf is recommended.  AuthorIgnatius.L代码:
C语言临时自用代码#include<stdio.h>#include<stdlib.h>#include<ctype.h>#include<string.h>typedef struct point{    struct point *child[26];    char name[11];}node,*Lnode;int m=sizeof(node);Lnode newtree(){    Lnode n;    int i;   n=(Lnode)malloc(m);   n->name[0]=0;    for(i=0;i<26;i++)       n->child[i]=NULL;    return n;}void Build(char str2[11],char str[11],Lnode tree){    Lnode p,s;    int i;   p=tree;    for(i=0;str[i];i++)    {        if(p->child[str[i]-'a']==NULL)        {           s=newtree();           p->child[str[i]-'a']=s;           p=s;        }        else p=p->child[str[i]-'a'];    }    strcpy(p->name,str2);}char* search(char str[11],Lnode tree){    Lnode p;    int i;   p=tree;    for(i=0;str[i];i++)    {        if(p->child[str[i]-'a']==NULL)return str;       p=p->child[str[i]-'a'];    }    if(p->name[0]!=0)        return p->name;    else return str;}int main(){    int i,j;    char str[11],str2[11],str1[3001],*s;    gets(str);    Lnode tree;    tree=newtree();    while(scanf("%s",str2),strcmp(str2,"END")!=0)    {        scanf("%s",str);   
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: