public class Anagrams
{
static void Main()
{
Console.WriteLine("Enter a first string :");
string str1 =
Console.ReadLine().ToLower().Trim();
Console.WriteLine("Enter a second string :");
string str2 =
Console.ReadLine().ToLower().Trim();
if (str1.Length ==
str2.Length)
{
int count = 0;
for (int i = 0; i < str1.Length; i++)
{
count = 0;
for (int j = 0; j < str2.Length; j++)
{
char c1 = str1[i];
char c2 = str2[j];
if (c1 == c2)
{
count = 1;
}
}
if (count == 0)
{
break;
}
}
if (count > 0)
{
Console.WriteLine("it is anagrams
string");
}
else
{
Console.WriteLine("It is not
anagrams string");
}
}
else
{
Console.WriteLine("both string
are not matching");
}
Console.ReadLine();
}
}
Output:
No comments:
Post a Comment