#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char str1[] = "sdfgkirertyujvcheddirtyutrdfgrtyuigfkrertyuijhgfdshh";
char str2[] = "redirtyhgfdshhrtyrsujvcheierdutrdfgrtyuigfkdfgktyuij";
int len1 = strlen(str1), len2 = strlen(str2);
if(len1 != len2)
{
cout<<"Both are not anagram of each other.";
return 0;
}
else
{
int rep_char1[26] = {0}, rep_char2[26] = {0}, i;
for(i=0; i<len1; i++)
{
rep_char1[str1[i]-'a']++;
rep_char2[str2[i]-'a']++;
}
for(i=0; i<26; i++)
if(rep_char1[i] != rep_char2[i])
{
cout<<"Both are not anagram of each other.";
return 0;
}
cout<<"Both are anagram of each other.";
}
return 0;
}
--
Siddharth Kumar
BE 4th year, Computer Engineering
(Delhi College of Engineering)
+919711559760
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.