Nathan wants to implement wildcard pattern matching supporting only the wildcard '?'. The wildcard character '?' can be substituted by any single lower case English letter for matching. He has two strings X and Y of equal length, made up of lower case letters and the character '?'. He wants to know whether the strings X and Y can be matched or not.
#include <stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{int MAX=10;
char a[MAX],b[MAX];
int t;
scanf("%d",&t); while(t--){
scanf("%s",a); scanf("%s",b);
int i,
n=strlen(b),no=0;
for(i=0;i<n;i++)
{if(isalpha(a[i])&&isalpha(b[i])&&a[i]!=b[i])
no++;}
if(no>0)
printf("No\n");
else printf("Yes\n"); }
return 0;
}
Comments
Post a Comment