#include <iostream>
using namespace std;
bool isMatch(const char *s, const char *p) {
const char* star=0;
while (*s){
if ((*p=='?')||(*p==*s)){
s++;
p++;
continue;
}
else if (*p=='*'){
star=p;
p++;
continue;
}
else if (star){
p = star+1;
if(!*++s){
if(!*p) {
p++;
}
}
continue;
}
return false;
}
while (*p=='*'){
p++;
}
return !*p;
}
int main() {
// your code goes here
const char *s = "aa";
const char *p = "a*";
cout << isMatch(s, p);
}