Count of common characters in two strings
C CODE:
#include<stdio.h>
#include <stdlib.h>
int main()
{
char s1[100],s2[100];
scanf("%s",s1);
scanf("%s",s2);
int l1,l2,i,j,k=0,y=0;
l1=strlen(s1);
l2=strlen(s2);
for(i=0;i<l1;i++)
{
for(j=i+1;j<l1;j++)
{
if(s1[i]==s1[j])
{
s1[j]='0';
}if(s2[i]==s2[j])
{
s2[j]='1';
}
}
}
for(i=0;i<l1;i++)
{
for(j=0;j<l2;j++)
{
if(s1[i]==s2[j])
{
y++;
s1[i]='2';
s2[j]='8';
}
}
}
printf("%d",y);
}
this is not working for me
ReplyDeletethis is not working
ReplyDeleteit shows core dumped
ReplyDeleteWtf
ReplyDelete