标签:
class Solution { public: bool isMatch(const char *s, const char *p) { if (s == NULL || p == NULL) return false; int slen = 0; int plen = 0; while (s[slen] != ‘\0‘) slen++; while (p[plen] != ‘\0‘) plen++; if (slen == 0 && plen == 0) return true; if (plen == 0) return false; int si = 0; int pi = 0; int ppi = -1; int psi = 0; while (si < slen) { if (s[si] == p[pi] || p[pi] == ‘?‘) { si++, pi++; } else if (p[pi] == ‘*‘) { ppi = pi++; psi = si; } else if (ppi != -1){ pi = ppi + 1; si = ++psi; } else { return false; } } while (p[pi] == ‘*‘) pi++; return pi == plen; } };
真写不出这样的代码。
参考:http://www.cnblogs.com/zhuli19901106/p/3572736.html
标签:
原文地址:http://www.cnblogs.com/lailailai/p/3870794.html