#include <iostream>
#include <algorithm>
bool areAnagrams(const std::string& str1, const std::string& str2) {
// Check if the lengths of the strings are equal
if (str1.length() != str2.length()) {
return false;
}
// Sort both strings
std::string sortedStr1 = str1;
std::string sortedStr2 = str2;
std::sort(sortedStr1.begin(), sortedStr1.end());
std::sort(sortedStr2.begin(), sortedStr2.end());
// Compare the sorted strings
return sortedStr1 == sortedStr2;
}
int main() {
// Input two strings
std::string inputStr1, inputStr2;
std::cout << "Enter the first string: ";
std::cin >> inputStr1;
std::cout << "Enter the second string: ";
std::cin >> inputStr2;
// Check if the input strings are anagrams
if (areAnagrams(inputStr1, inputStr2)) {
std::cout << "The strings are anagrams." << std::endl;
} else {
std::cout << "The strings are not anagrams." << std::endl;
}
return 0;
}