版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ShellDawn/article/details/89061361
这题没写出来。。。。
class Solution {
public:
bool solve(char* a,char* b){
if(*a == 0 && *b == 0) return true;
if(*a != 0 && *b == 0) return false;
if(*(b+1) == '*'){
if(*a == *b || *b == '.' && *a != 0){
return solve(a+1,b+2) ||
solve(a+1,b) ||
solve(a,b+2);
}else{
return solve(a,b+2);
}
}
if(*a == *b || *b == '.' && *a != 0){
return solve(a+1,b+1);
}
return false;
}
bool match(char* str, char* pattern)
{
if(str == NULL || pattern == NULL) return false;
return solve(str,pattern);
}
};