-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSubstring_Recursive_search_in_cpp.cpp
67 lines (51 loc) · 1.19 KB
/
Substring_Recursive_search_in_cpp.cpp
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mp make_pair
#define pb push_back
#define loop(x,n) for(int x = 0; x < n; x++)
#include <bits/stdc++.h>
#define RANGE 255
using namespace std;
long long int input(){
ll n;
cin>>n;
return n;
}
bool Match(char *text, char *pat)
{
if (*text == '\0' && *pat != '\0')
return false;
if (*pat == '\0')
return true;
if (*text == *pat)
return Match(text + 1, pat + 1);
return false;
}
bool check(char *text, char *pat)
{
if (*text == '\0')
return false;
if (*text == *pat)
if(Match(text, pat))
return 1;
else
return check(text + 1, pat);
return check(text + 1, pat);
}
int main() {
/*#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif*/
ios::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
int t;
cin>>t;
while(t--){
char s1[100],s2[100];
cin>>s1>>s2;
cout<<check(s1,s2);
cout<<"\n";}
}