HDU 1075 What is your talking about (give you a dictionary, let you translate sentences, words not found in the dictionary do not translate)

Source: Internet
Author: User

1. This is a dictionary tree problem, but you can do it with map

2. Code:

#include <cstdio> #include <cstring> #include <iostream> #include <map>using namespace Std;map    <string,string> Mp;char S[30100],ss[15];int Main () {scanf ("%s", s);        while (1) {scanf ("%s", s);        if (strcmp (S, "END") ==0) break;        scanf ("%s", SS);        String s1,s2;        int Len1=strlen (s);        int Len2=strlen (ss);        for (int i=0; i<len1; i++) {s1+=s[i];        } for (int i=0; i<len2; i++) {s2+=ss[i];    } mp.insert (Make_pair (S2,S1));    } Map<string,string>::iterator it; /*for (It=mp.begin (); It!=mp.end (); it++) {cout<< (It->first) << "" << (It->second) <<end    L    }*/scanf ("%s", s);    GetChar ();        while (1) {gets (s);        GetChar ();        if (strcmp (S, "END") ==0) {break;        } int Len=strlen (s);        S[len]= ";        String sss;      for (int i=0; i<=len; i++)  {if (s[i]>=97&&s[i]<=122) {sss+=s[i];                        } else {if (sss.size () ==0) {if (I!=len)                    cout<<s[i];                Continue                    } else {it=mp.find (SSS);                    if (It!=mp.end ()) {cout<<it->second;                    } else {cout<<sss;                    } if (I!=len) cout<<s[i];                Sss.clear ();    }}} cout<<endl; } return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDU 1075 What is your talking about (give you a dictionary, let you translate sentences, words not found in the dictionary do not translate)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.