-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path52.cpp
More file actions
29 lines (26 loc) · 744 Bytes
/
52.cpp
File metadata and controls
29 lines (26 loc) · 744 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
#include <iostream>
using namespace std;
bool match(char *str, char *pattern) {
if (*str == '\0' && *pattern == '\0')
return true;
if (*str != '\0' && *pattern == '\0')
return false;
if (*(pattern + 1) != '*') {
if (*str == *pattern || (*str != '\0' && *pattern == '.'))
return match(str + 1, pattern + 1);
else
return false;
} else {
if (*str == *pattern || (*str != '\0' && *pattern == '.'))
return match(str, pattern + 2) || match(str + 1, pattern);
else
return match(str, pattern + 2);
}
}
int main() {
ios::sync_with_stdio(false);
char a[101], b[101];
cin >> a >> b;
cout << match(a, b);
return 0;
}