#include <iostream>
#include <string>
using namespace std;
bool isAnagram(const string &str1, const string &str2);
int main()
{
string mystringOne;
string mystringTwo;
cout << "ANIGRAM MACHINE" << endl << endl;
cout << "Enter word one --> ";
cin >> mystringOne;
cout << "Enter Word two --> ";
cin >> mystringTwo;
cout << endl;
if(isAnagram(mystringOne,mystringTwo))
{
cout << mystringOne << " and " << mystringTwo << " are anagrams!" << endl;
}
else
{
cout << mystringOne << " and " << mystringTwo << " are NOT anagrams!" << endl;
}
return 0;
}
bool isAnagram(const string &s1, const string &s2)
{
for(int i = 0; i < s1.length(); i++)
{
if(s2.find(s1[i]) == string::npos)
{
return false;
}
if(s1.find(s2[i]) == string::npos)
{
return false;
}
}
if(s1 == s2) return true;
return true;
}