Wildcard Matching
2015-11-10 20:06
399 查看
<pre style="margin-top: 0px; margin-bottom: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-size: 13px; line-height: 19.5px; background-color: rgb(245, 245, 245);">isMatch("aa","a") → false isMatch("aa","aa") → true isMatch("aaa","aa") → false isMatch("aa", "*") → true isMatch("aa", "a*") → true isMatch("ab", "?*") → true isMatch("aab", "c*a*b") → false
bool isMatch(const char *s, const char *p) { if (s == NULL || p == NULL) return false; if (*p == '\0') return *s == '\0'; if (*p == '*') { while (*p == '*') ++p; while (*s != '\0') { if (isMatch(s, p)) return true; ++s; } return isMatch(s, p); } else if ((*s != '\0' && *p == '?') || *p == *s) { return isMatch(s + 1, p + 1); } return false; }
相关文章推荐
- 使用grunt合并压缩js、css文件
- AutoLayout(自动布局)入门
- 20135223何伟钦—第六章家庭作业
- 阿里云服务器远程mysql连不上
- Rational Rose 2003 下载、破解及安装方法(图文)
- HDU 1276 士兵队列训练问题 标记
- 插入排序
- sicily 14550 Interesting Integers
- python表达式操作符与数学函数
- LeetCode Add Two Numbers(用链表模拟加法)
- Odd-even sort: Sorting by Exchanging
- Java web eclipse 配置-workset tab转空格
- git删除文件所有历史版本
- leetcode 48:Rotate Image
- MySQL 源码编译安装报错 Googlemock was not found
- opencv笔记 1.利用摄像头进行视频文件写入
- c++primer第五版第十二章12.20习题用一个StrBlobPtr打印出StrBlob中的元素
- 【jdbcTemplate】使用jdbcTemplate查询的三种回调
- 驱动模块和桩模块的概念和区别
- [2033 ] :人见人爱A+B