#include <cstdio>
#include <string>
using namespace std;
char hotel[100], Lu[100];
int len, len1;
bool dfs(int a, int b){
if (a == len1 && b == len)
return true;
if (a == len1 || b == len)
return false;
if (hotel[a] == '?' || hotel[a] == Lu[b])
return dfs(a + 1, b + 1);
if (hotel[a] == '*'){
for (int i = b; i <= len; i++)
if (dfs(a + 1, i))//找下一个能匹配的情况
return true;
}
return false;
}
int main(){
int n;
while (scanf("%s", hotel) != EOF){
scanf("%d", &n);
len1 = strlen(hotel);
int sum = 0;
while (n--){
scanf("%s", Lu);
len = strlen(Lu);
if (dfs(0, 0)){
sum++;
}
}
printf ("%d\n", sum);
}
return 0;
}
HDU ACM 16 2585 hotel
最新推荐文章于 2018-08-08 22:19:26 发布