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. git 对文件大小写修改无反应 不敏感解决办法

    git config core.ignorecase false 执行之后就能自动检测到了 2019-01-18

  2. JsonCpp在vs中使用

    Jsoncpp是c++生成和解析Json数据的跨平台开源库.下面简介如何在vs中使用. 1.官网下载.https://sourceforge.net/projects/jsoncpp/解压文件得到js ...

  3. PHP | 获取数组长度的方法

    一.获取一维数组的长度 count.sizeof 都可以直接统计一维数组长度. 例如:$arr = Array('0','1','2','3','4');       echo count($arr) ...

  4. 【读书笔记 - Effective Java】04. 通过私有构造器强化不可实例化的能力

    工具类(utility class)不希望被实例化,比如只包含静态方法和静态域的类.为了这个目的,需要让这个类包含一个私有构造器. // 私有构造器示例 public class UtilityCla ...

  5. 浏览器端用JS实现创建和下载图片

    问题场景 在前端很多的项目中,文件下载的需求很常见.尤其是通过JS生成文件内容,然后通过浏览器端执行下载的操作.如图片,Execl 等的导出功能.日前,项目中就遇到了这类需求,在浏览器端实现保存当前网 ...

  6. MySQL---下载安装、数据库基本操作

    1.下载安装 1.1 下载:  http://dev.mysql.com/downloads/mysql/ 1.2 解压 1.3 初始化 cd c:\mysql-5.7.16-winx64\bin ( ...

  7. xshell安装教程

    Xshell安装使用教程 Xshell 是一个强大的安全终端模拟软件,它支持SSH1, SSH2, 以及Microsoft Windows 平台的TELNET 协议.Xshell 通过互联网到远程主机 ...

  8. Maven安装配置环境变量及eclipse的配置

    Maven安装与配置   一.需要准备的东西 1. JDK 2. Eclipse 3. Maven程序包 二.下载与安装 1. 前往https://maven.apache.org/download. ...

  9. 帝国cms伪静态设置方法(收藏)

    众所周知,动态页面不利于收录和排名.伪静态可以完美的解决这问题,配合百度云加速CDN,可以让动态页面有静态页面一样快的访问速度. 今天开拓族给大家带来帝国CMS伪静态的详细设置方法. 1.栏目设置为动 ...

  10. while 循环,格式化输出和运算编码

    今日内容 1.while循环 while Ture:             content = input ("请输入你要喷的内容",输入Q退出)             if ...