Description

Have you ever used file searching tools provided by an operating system? For example, in DOS, if you type "dir *.exe", the OS will list all executable files with extension "exe" in the current directory. These days, you are so mad with the crappy operating system you are using and you decide to write an OS of your own. Of course, you want to implement file searching functionality in your OS.

Input

The input contains several test cases. Consecutive test cases are separated by a blank line. Each test case begins with an integer N (1 <= N < =100), the number of files in the current directory. Then N lines follow, each line has one string consisting of lowercase letters ('a'..'z') and the dot ('.') only, which is the name of a file. Then there is an integer M (1 <= M <= 20), the number of queries. M lines follow, each has one query string consisting of lowercase letters, the dot and the star ('*') character only. Note that the star character is the "universal matching character" which is used to represent zero or numbers of characters that are uncertain. In the beginning, you just want to write a simple version of file searching, so every string contains no more than 64 characters and there is one and only one star character in the query string. Process to the End Of File (EOF).

Output

For each test case, generate one line for the results of each query. Separate file names in the result by a comma (',') and a blank (' ') character. The file names in the result of one query should be listed according to the order they appear in the input. If there is no matching file, output "FILE NOT FOUND" (without the quotation) instead. Separate two consecutive test cases with a blank line, but Do NOT output an extra blank line after the last one.

Sample Input

4
command.com
msdos.sys
io.sys
config.sys
2
com*.com
*.sys 3
a.txt
b.txt
c.txt
1
*.doc

Sample Output

command.com
msdos.sys, io.sys, config.sys FILE NOT FOUND
 #include<stdio.h>
#include<string.h>
int main()
{
int n,m,i,j,len1,len2,x,y,z;
int flag1=,pos,count;
char s1[][],s2[][];
while(scanf("%d",&n)!=EOF)
{
getchar();
for(i=; i<n; i++)///输入文件名
{
gets(s1[i]);
}
scanf("%d",&m);///输入搜索
getchar();
for(i=; i<m; i++)
{
gets(s2[i]);
}
for(i=; i<m; i++)
{
count=;
for(j=; j<n; j++)
{
len1=strlen(s1[j]);
len2=strlen(s2[i]) ;
for(x=; x<len2; x++)///查找星号标志
{
if(s2[i][x]=='*')
{
pos=x;///标记星号
break;
}
}
flag1=;
for(y=; y<pos; y++) ///左边
{
if(s1[j][y]!=s2[i][y])
{
flag1=;
break;
}
}
if(flag1)
{
continue;
}
for(z=; z<len2-pos; z++)///右边
{
if(s1[j][len1-z]!=s2[i][len2-z])
{
flag1=;
break;
}
}
if(flag1)
{
continue;
}
if(flag1==)
{
if(count>=)/// 输出含有逗号的多组结果,学习这种控制方法
printf(", %s",s1[j]);
else
printf("%s",s1[j]);
count++;
}
}
if(count==)
printf("FILE NOT FOUND");
printf("\n");
}
printf("\n");
}
return ;
}

File Searching的更多相关文章

  1. execve(file, argv, env)参数argv获取字符串个数

    /* Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU ...

  2. Java性能提示(全)

    http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...

  3. Linux 进程与信号的概念和操作

    进程 主要参考: http://www.bogotobogo.com/Linux/linux_process_and_signals.php 信号与进程几乎控制了操作系统的每个任务. 在shell中输 ...

  4. 拼写纠错的利器,BK树算法

    BK树或者称为Burkhard-Keller树,是一种基于树的数据结构,被设计于快速查找近似字符串匹配,比方说拼写纠错,或模糊查找,当搜索”aeek”时能返回”seek”和”peek”. 本文首先剖析 ...

  5. 转:pycharm community debug django projects

    原文:https://automationpanda.com/2017/09/14/django-projects-in-pycharm-community-edition/comment-page- ...

  6. Linux 进程与信号的概念和操作 linux process and signals

    进程 主要参考: http://www.bogotobogo.com/Linux/linux_process_and_signals.php 译者:李秋豪 信号与进程几乎控制了操作系统的每个任务. 在 ...

  7. 最新Mac安装CocoaPods详细教程及各种坑解决办法

    网上有很多教程,但要么内容很老,要么不详细,要么各种坑的情况没写.最近买新电脑了,正好要走一遍这些流程,所以写下次教程. 一.安装RVM及更新Ruby 安装RVM的目的是为了更新Ruby,如果你的Ru ...

  8. Trie(前缀树/字典树)及其应用

    Trie,又经常叫前缀树,字典树等等.它有很多变种,如后缀树,Radix Tree/Trie,PATRICIA tree,以及bitwise版本的crit-bit tree.当然很多名字的意义其实有交 ...

  9. Arch系统软件列表

    1. 安装统计 2. 安装列表 3. 安装说明 4. 作为依赖项的安装列表 5. 更正 mangaro使用减的方式安装系统.开箱即用的豪华版本,大部分人需要的都有了,同样包括个别用户不需要的,配置方面 ...

随机推荐

  1. shell基础知识---与监听服务器长连接端口状态

    从未写过脚本我的最近接了俩脚本的需求,就在这分享一下我的我学到基础知识主要就四部分内容 一.变量 变量的定义 string='字符串' string="字符串" num=808st ...

  2. css 浮动说明

    clear:both; 1.要了解的:什么是浮动.浮在某面板之上. 例如:float:left; 向左停靠, 就是让需要设置浮动的元素,跟在指定元素后面. 先上实例: 比较常用导航: .nav_ul ...

  3. Ruby中的类

    初识ruby中的类 只需要简单的两行 class Point end 如果我们此时实例化一个类那么他会有一些自省(introspection)的方法 p = Point.new p.methodes( ...

  4. Wake-Sleep(W-S)算法【转载】

    原文: https://www.zhihu.com/question/29648549 https://blog.csdn.net/zouxy09/article/details/8775518 en ...

  5. C# 使用cmd

    public static string cmd(String command) //向cmd()传入命令行,传入"exit"则退出cmd.exe. { Process p = n ...

  6. Docker入门系列01

    前两篇写了 Docker 如何安装和相关的概念,当然概念的东西省略了很多,主要是自己水平有限,所以后期会可能增添.但以上内容都是用别人的建好的 镜像(Image) ,这怎么行,我们应该自己动手造轮子, ...

  7. Java-谈谈对Java平台的理解

    问题 谈谈对 Java 平台的理解 Java是解释执行的 这句话对么 程序的编译与解释有什么区别 Java 平台的了解 Java的主要特点是两个, 编写一次到处运行 Write once, run a ...

  8. [原创]利用python构造ICMP Echo Request并发送

    import socket import struct def checksum(source_string): sum = 0 countTo = (len(source_string)/2)*2 ...

  9. Python科学计算器(计算器)

    说明 该计算器主要是为了练习正则表达式以及python基础所写:代码比较low! 运行过程 请输入你的计算公式, 计算器会将计算结果输出到屏幕上(此处会打印步骤); 退出(exit/quit) MyC ...

  10. Spring框架之Filter应用

    在web.xml中进行配置,对所有的URL请求进行过滤,就像"击鼓传花"一样,链式处理. 配置分为两种A和B. 在web.xml中增加如下内容: <filter> &l ...