-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day_041.cpp
44 lines (35 loc) · 867 Bytes
/
Day_041.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
/**
*Problem Statement: a Program to Check if two strings match where one string contains wildcard characters.
*Author: Kunal Kathpal (https://github.com/kunal-2002)
*/
#include <bits/stdc++.h>
using namespace std;
bool checking(char* A, char* B){
if(*A == '\0' && *B == '\0')
return true;
if(*A == '*' && *(A+1) != '\0' && *B == '\0')
return false;
if(*A == '?' || *A == *B)
return checking(A+1,B+1);
if(*A == '*')
return checking(A+1,B) || checking(A, B+1);
return false;
}
void testing(char* A, char* B){
checking(A,B)?puts("Yes"):puts("No");
}
int main(){
cout<<"Enter number of test cases:\t";
int T;
cin>>T;
while(T--){
char A[20], B[20];
cout<<"Enter first string with wild characters:\t";
cin>>A;
cout<<"Enter second string without wild characters:\t";
cin>>B;
testing(A,B);
cout<<endl;
}
return 0;
}