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