#include <string>
#include <iostream>
usingnamespace std;
// Postcondition: the return value is true if s1 and s2 are anagrams
// of each other
bool anagram(string s1, string s2)
{
string temp = s2;
int i;
for (i=0; i<s1.length(); i++);
{
// invariant: temp is s2 with first copy of chars 0..i-1
// of s1 removed
string newtemp = "";
bool found = false;
if (temp.length()==0)
{returnfalse;}
for (int j=1; j<temp.length(); j++)
{
if (!found && (s1[i] = temp[j]))
found = true;
else
newtemp = newtemp + temp[j];
};
// assert: newtemp is temp with first occurrence of s1[i] removed
temp = newtemp;
};
return (temp.empty());
}
int main() {
string str1, str2;
if (anagram("sjkf",""))
{cout << "true"; }
cout << "Enter two strings: ";
cin >> str1 >> str2;
if (anagram(str1,str2))
cout << "The strings are anagrams!\n";
else
cout << "The strings are NOT anagrams.\n";
return 0;
}