Vimal has found two very old sheets of paper, each of which originally contained a string of lowercase Latin letters. The strings on both the sheets have equal lengths. However, since the sheets are very old, some letters have become unreadable.Vimal would like to estimate the difference between these strings. Let's assume that the first string is named S1, and the second S2. The unreadable symbols are specified with the question mark symbol '?'. The difference between the strings equals to the number of positions i, such that S1i is not equal to S2i, where S1i and S2i denote the symbol at the i the position in S1 and S2, respectively.Vimal would like to know the minimal and the maximal difference between the two strings, if he changes all unreadable symbols to lowercase Latin letters. Now that you're fully aware of Vimal's programming expertise, you might have guessed that he needs you help solving this problem as well. Go on, help him!
#include<stdio.h>
int main()
{
int t,minimal,maximal,count,i;
char S1[101],S2[101];
scanf("%d",&t);
while(t--)
{scanf("%s %s",S1,S2);
i=0;
count=minimal=maximal=0;
while(S1[i]!='\0')
{if(S1[i]=='?'||S2[i]=='?')
count++;
else if(S1[i]!=S2[i])
minimal++;
i++;
}
maximal=minimal+count;
printf("%d %d\n",minimal,maximal);
}
return 0;
}
Comments
Post a Comment