-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path44.c
More file actions
49 lines (46 loc) · 843 Bytes
/
44.c
File metadata and controls
49 lines (46 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
bool isMatch(char * s, char * p){
int i = 0;
int j = 0;
int match = 0;
int star = -1;
while(i < strlen(s))
{
if(j < strlen(p) && (p[j] == '?' || s[i] == p[j]))
{
i++;
j++;
}
else if(j < strlen(p) && p[j] == '*')
{
star = j;
match = i;
j++;
}
else if(star != -1)
{
j = star + 1;
i = ++match;
}
else
{
return false;
}
}
while(j < strlen(p) && p[j] == '*')
{
j++;
}
return j == strlen(p);
}
int main()
{
char s[2001], p[2001];
scanf("%s", s);
scanf("%s", p);
bool ans = isMatch(s, p);
printf("%d", ans);
return 0;
}