题目描述
问题描述:在计算机中,通配符一种特殊语法,广泛应用于文件搜索、数据库、正则表达式等领域。现要求各位实现字符串通配符的算法。
要求:
实现如下2个通配符:
*:匹配0个或以上的字符(字符由英文字母和数字0-9组成,不区分大小写。下同)
?:匹配1个字符
输入:
通配符表达式;
一组字符串。
输出:
返回匹配的结果,正确输出true,错误输出false
#include<string>
#include<iostream>
#include<vector>
using namespace std;
int match_string(string m_str,string w_str) //match wildcard 通配符
{
int m_len = m_str.size();
int w_len = w_str.size();
vector<vector<int> > b_dp(w_len+1,vector<int>(m_len+1,0));
//多加一行一列作为初始初值所用
b_dp[0][0] = 1;
for(int i=1;i <=w_len;i++)
{
char ch = w_str[i-1];
设置每次循环的初值,即当星号不出现在首位时,匹配字符串的初值都为false
b_dp[i]