FINDING COMMON ALPHABETS B/W TWO GIVEN STRINGS
#include<iostream>
using namespace std;
int main()
{
int len1, len2, x;
string s1="AJITH KUMAR", s2="PRAVEEN R";
len1= s1.length();
len2= s2.length();
for(int i=0;i<len1;i++)
{
for(int j=0;j<i;j++)
{
if(s1[i]==s1[j])
{
x=0;
break;
}
}
if(x==0)
{
x= 1;
continue;
}
for(int k=0;k<len2;k++)
{
if(s2[k]==s1[i])
{
cout<<s1[i]<<" ";
break;
}
}
}
return 0
}
No comments:
Post a Comment