#include <iostream>
#include<string>
using namespace std;
int isAnagram(string str1,string str2) {
int count1[26] = {0}, count2[26] = {0}, i = 0;
int x;
while (str1[i] != '\0') {
x=tolower(str1[i])-97;
count1[x]+=1;
i++;
}
i = 0;
while (str2[i] != '\0') {
x=tolower(str2[i])-97;
count2[x]+=1;
i++;
}
for (i = 0; i < 26; i++) {
if (count1[i] != count2[i])
return 0;
}
return 1;
}
int main() {
string str1,str2;
char repeat ('y');
do {
cout << "Enter first string: ";
getline(cin,str1);
cout << "Enter second string: ";
getline(cin,str2);
if (isAnagram(str1, str2))
cout << endl << "\"" << str1 << "\" and \"" << str2 << "\" are anagrams." << endl;
else
cout << endl << "\"" << str1 << "\" and \"" << str2 << "\" are not anagrams." << endl;
cout << endl << "Try again [Y]es [N]o > ";
cin >> repeat;
} while (tolower(repeat) == 'y');
return 0;
}