在查询中的字符串最小的匹配的过程,怎么用C语言的程序的编写的技术加以的实现

Problem Description
For this problem you will write a search engine that takes a query, searches a collection of words, and finds the lexicographically smallest word that matches the query (i.e., the matching word that would appear first in an English dictionary). A query is a sequence of one or more terms separated by single vertical bars ("|"). A term is one or more letters followed by zero or more signed letters. A signed letter is either +s ("positive" s) or -s ("negative" s), where s is a single letter. All letters are lowercase, and no letter will appear more than once within a term. A query will not contain spaces. A term matches a word if the word contains at least one of the unsigned letters, all of the positive letters, and none of the negative letters; a query matches a word if at least one of its terms matches the word.

Input
The input consists of one or more test cases followed by a line containing only "#" that signals the end of the input. Each test case consists of 1–100 words, each on a line by itself, followed by a line containing only "*" that marks the end of the word list, followed by one or more queries, each on a line by itself, followed by a line containing only "**" that marks the end of the test case. Each word will consist of 1–20 lowercase letters. All words within a test case will be unique. Each query will be as defined above and will be 1–79 characters long.

Output
For each query, output a single line containing the lexicographically smallest word within that test case that matches the query, or the word NONE if there is no matching word. At the end of each test case, output a dollar sign on a line by itself.

Sample Input
elk
cow
bat
*
ea
acm+e
nm+o|jk+l
**
debian
slackware
gentoo
ubuntu
suse
fedora
mepis
*
yts
cab-e+n
r-e|zjq|i+t|vs-p+e-u-c
**
#

Sample Output
bat
NONE
elk
$
gentoo
ubuntu
NONE
$

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

1
delphi 字符串查找或者匹配的问题?
4
怎么javascrpt语言实现将一个字符串转换为多个字符串构成的数组并且判断每个字符串的数组?
2
字符串怎么在jacvscropt语言里实现字符串的判断
3
javascpt语言怎么对字符串的类型用类型判断?怎么判断字符串属于的类型是什么?
0
初学字符串的实际工程问题4,5,6
2
如何用C语言字符串相关知识编写这个程序
3
如何用C语言字符串编程解决这个实际问题
1
C语言字符串的排序问题如何解决?
2
C语言:统计字符串中字符的种类
1
字符串查询的一个难点问题,怎么利用C语言匹配字符串?
0
一个字符串的匹配算法采用KMP的实现,字符串匹配怎么实现啊,用C语言
1
C语言计算实现,字符串的编码值小于等于给定的值则输出yes,否则输出no
1
用C语言如何解决:对于输入的每个字符串,查找其中的最大字母,在该字母后面插入字符串
0
根据存储空间判断这个字符串是否是安全的,运用C语言的程序实现的过程如何做?
0
给定的一个字符串,统计其中数字字符出现的次数,怎么采用C语言来回答这个问题的
0
字符串运用的查找最大元素,怎么采用C语言的程序代码编写的过程的方式去实现
1
输入一个字符串,可以删除字符串s中的任意字符,剩下的字符串形成对称字符串,且该字符串为最长对称字符串
0
要求输出s和t交叉组成的各种字符串组合中最长回文串的长度,这个问题用C语言写出代码怎么实现
2
指定位置输出字符串:输入一个字符串后再输入两个字符,输出此字符串中从与第一个字
2
文件中字符串的匹配判断输出的问题,怎么正确地运用 C语言的程序设计语言的编写代码的方式解决思想