Baiti 2804 dictionary solution report

Source: Internet
Author: User

1. Link: http://poj.grids.cn/practice/2804/

2. content

Total time limit:
3000 ms
Memory limit:
65536kB
Description
You traveled to a foreign city. You cannot understand the Foreign Languages people speak there. Fortunately, you have a dictionary to help you.
Input
First, enter a dictionary containing no more than 100000 entries. Each entry occupies one row. Each entry contains an English word and a foreign language word. The two words are separated by a space. In addition, no foreign language word appears more than twice in the dictionary. A dictionary is followed by a blank line. A document consists of a foreign language word. The document contains no more than 100000 lines and each line contains only one foreign language word. The input contains only lowercase letters and cannot exceed 10 characters in length.
Output
In the output, you need to translate the input document into English and output an English word in each line. If a foreign language word is not in the dictionary, it is translated into "eh ".
Sample Input
dog ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslay
Sample output
catehloops
Prompt
The input is large. c I/O functions are recommended.

3. code

 #include <stdio.h> #include <.h> #include <algorithm>    MAXSTR 11  MAXWORD 100010     typedef                  compare( * elem1, *       strcmp(((m_word*)elem1)->foreign,((m_word*)elem2)->          count =            chs[          (fgets(chs,,stdin),chs[] !=           sscanf(chs,         count++           qsort(m_dic,count,                m_word*     (scanf(,tmp.foreign) !=          ans = (m_word*)bsearch(&tmp,m_dic,count,                  (ans != NULL) printf(,ans->          printf(              }

4. method

(1) fgets + sscanf

(2) qsort + bsearch

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.