Write a simple spell checker. First you will read a set of words as a dictionary. Next you will read a set of word as text. For example our dictionary has apple
, apples
, orange
, banana
. All words are in lower case from 'a'
to 'z'
only.
For every word in text you must look up the dictionary and determine if the spelling is correct. If the word from text is in the dictionary, like apple, then you output a line >apple
.
If the word from text is not in the dictionary, you must list all possible candidates as ?apple apples
, in the order they appear in the dictionary. A word in the dictionary is a candidate if one of the following is true.
aqqle
.appple
.aple
.If you cannot find any candidate, simply output !aple
.
The first line contains an integer $N$ denoting the number of words in the dictionary. Followed by $N$ lines, each line contains a word $w_i$ denoting the $i$-th word in the dictionary. After $N+1$ lines, the next line contains an integer $Q$ denoting the number of words in text. Followed by $Q$ lines, each line contains a word $q_i$ denoting the $i$-th word in text.
5 case content contest common onganize 4 cases common context come
?case >common ?content contest !come
編號 | 身分 | 題目 | 主題 | 人氣 | 發表日期 |
沒有發現任何「解題報告」
|