Problem Description
Last year summer Max traveled to California for his vacation. He had a great time there: took many photos, visited famous universities, enjoyed beautiful beaches and tasted various delicious foods. It is such a good trip that Max plans to travel there one more time this year. Max is satisfied with the accommodation of the hotel he booked last year but he lost the card of that hotel and can not remember quite clearly what its name is. So Max searched 
in the web for the information of hotels in California ans got piles of choice. Could you help Max pick out those that might be the right hotel?
 
Input
Input may consist of several test data sets. For each data set, it can be format as below: For the first line, there is one string consisting of '*','?'and 'a'-'z'characters.This string represents the hotel name that Max can remember.The '*'and '?'is wildcard characters. '*' matches zero or more lowercase character (s),and '?'matches only one lowercase character.

In the next line there is one integer n(1<=n<=300)representing the number of hotel Max found ,and then n lines follow.Each line contains one string of lowercase character(s),the name of the hotel.
The length of every string doesn't exceed 50.

 
Output
For each test set. just simply one integer in a line telling the number of hotel in the list whose matches the one Max remembered.
 
Sample Input
herbert
2
amazon
herbert
 
?ert*
2
amazon
herbert
 
 
*
2
amazon
anything
 
herbert?
2
amazon
herber
 
Sample Output
1
0
2
0
 
字符串的模糊匹配,?可以当做都匹配的一个字符,遇到*时自带一个查找
 
 #include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string> using namespace std; char a[],b[];
int n,len1,len2,res; bool digital(int i,int j)
{
//结尾判定
if(i==len1&&j==len2)
return true;
else if(i==len1||j==len2)
return false;
//中间过程
else if(a[i]=='*')
{
for(int k=j;k<=len2;k++)
if(digital(i+,k))
return true;
}
else if(a[i]=='?'||a[i]==b[j])
digital(i+,j+);
else
return false;
} int main()
{
while(scanf("%s",&a)!=EOF)
{
scanf("%d\n",&n);
len1=strlen(a);
res=;
while(n--)
{
scanf("%s",&b);
len2=strlen(b);
if(digital(,))
res++;
}
printf("%d\n",res);
}
return ;
}

HDU 2585 Hotel(字符串的模糊匹配+递归)的更多相关文章

  1. HDU 2585 [Hotel]字符串递归处理

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2585 题目大意:马克思要找个曾经去过的很好的旅馆,可惜他记不完整旅馆的名字.他有已知的部分信息和可能的 ...

  2. HDU 1274 展开字符串 (递归+string类)

    题目链接:HDU 1274 展开字符串 中文题. 左括号进入DFS函数,右括号return到上一层. 注意return回去的是这个一层递归中的括号中的字母串. AC代码: #include<st ...

  3. C++实现的字符串模糊匹配

    C++基本没有正则表达式功能,当然像Boost里提供了正则.本文来源于博客园园友的一篇文章,请看: C/C++ 字符串模糊匹配 很早之前就看过这篇文章,原作者的需求很明确.代码实现也很好. 之所以又写 ...

  4. mysql 两张表字段模糊匹配--字符串拼接函数

    concat(A,B,C,...)  拼接字符串 例如concat('123','***','345')  =>123***345 SELECT concat( substr(t1.CODE, ...

  5. 简单易用的字符串模糊匹配库Fuzzywuzzy

    简单易用的字符串模糊匹配库Fuzzywuzzy 阅读目录 FuzzyWuzzy 简介 安装 用法 已知移植 FuzzyWuzzy 简介 FuzzyWuzzy 是一个简单易用的模糊字符串匹配工具包.它依 ...

  6. dev 中 字符串转中文拼音缩写,对grid列表进行模糊匹配,grid获取焦点行,gridlookupedit控件用拼音模糊匹配下拉选项

    番外篇:. //该方法是将字符串转化为中文拼音的首写字母大写, public static string RemoveSpecialCharacters(string str){try{if (str ...

  7. 使用vlookup的模糊匹配和字符串拼接

    1,=IF(ISNA(VLOOKUP("*"&$D2&"*",$A$2:$A$43,1,FALSE))=FALSE,TRUE,FALSE) 2, ...

  8. sql模糊匹配中%、_的处理

    防sql注入之模糊匹配中%._处理: StringBuilder sbSql = new StringBuilder(); sbSql.Append(@"SELECT * from tabl ...

  9. Mysql 模糊匹配和转义字符

    首先创建一个测试表: insert into test(tt) values('\\\\172.18.28.153'); 现在我想使用模糊匹配,查出以 “\\172” 开头的字符串. 需要使用like ...

随机推荐

  1. java XML(可扩展标记语言)

    XML 是EXtensible Markup Language的缩写,它是一种类似于HTML的标记语言,称为可扩展标记语言,传输数据而不是显示数据,可以自定义标签,具有自我描述性是一种通用的数据交换格 ...

  2. Oracle11g温习-第十七章:权限管理

    2013年4月27日 星期六 10:50 1.权限(privilege):     [system privilege(系统权限):针对于database 的相关权限         object p ...

  3. Leetcode 150

    class Solution { public: int evalRPN(vector<string>& tokens) { stack<int> st; ;i < ...

  4. [CodeForces - 614D] D - Skills

    D - Skills Lesha plays the recently published new version of the legendary game hacknet. In this ver ...

  5. js修改样式

    添加.删除class: $("#id").addClass("someClass"); $("#id").removeClass(" ...

  6. pandas dataframe 过滤——apply最灵活!!!

    按照某特定string字段长度过滤: import pandas as pd df = pd.read_csv('filex.csv') df['A'] = df['A'].astype('str') ...

  7. Tomcat禁用SSLv3和RC4算法

    1.禁用SSLv3(SSL 3.0 POODLE攻击信息泄露漏洞(CVE-2014-3566)[原理扫描]) 编缉$CATALINA_HOEM/conf/server.xml配置文件,找到https端 ...

  8. WINDOWS中, 如何查看一个运行中的程序是64位还是32位的

    转自:https://blog.csdn.net/dayday3923/article/details/78597453?locationNum=7&fps=1 方法一: 任务管理器法任务管理 ...

  9. svn分支使用 SVN trunk(主线) branch(分支) tag(标记) 用法详解和详细操作步骤

    比较好的介绍了分支的创建和使用. 转:http://blog.csdn.net/vbirdbest/article/details/51122637

  10. 【HTTP】boundary 中一个 = 导致HTTP上传文件失败

    (1)#define ABOUNDARY "----=_Resume_002_0CE7_01D1C649.298A8070" (2)#define ABOUNDARY " ...