【发布时间】:2015-11-04 21:24:05
【问题描述】:
我一直在用 C++ 编写递归通配符匹配算法。但我无法完成它。这里看看我到目前为止写的内容。
? 匹配任意字符,* 匹配任意字符串
bool WildCardMatch(char *str, char *match){
while (*match){
if (*match =='?'){
if (!*str){
return false;
}
str++;
match++;
}
else if (*match == '*'){
if (WildcardMatch(str, match + 1)){
return true;
}
return false;
}
}
return !*str && !*match;
}
我的算法有什么问题?我应该如何解决它?或者有人可以建议我为递归通配符匹配算法提供更好的解决方案吗?
【问题讨论】:
-
有什么症状?
标签: c++ string algorithm recursion wildcard