- #include <iostream> 
- #include <string> 
-   
- using namespace std; 
-   
- bool isAnagram(const string &s1, const string &s2); 
-   
- int main () 
- { 
- 	string one(" "); 
- 	string two(" "); 
-   
- 	cout << "ENTER FIRST WORD: " << '\n'; 
- 	cin >> one; 
- 	cout << "ENTER SECOND WORD: " << '\n'; 
- 	cin >> two; 
-   
- 	isAnagram(one,two); 
- 	system("pause"); 
- 	return 0; 
- } 
-   
-   
- bool isAnagram(const string &s1, const string &s2) 
- { 
- 	int countsA[256]; 
- 	int countsB[256]; 
-   
- 	int iCountOne = s1.length(); 
- 	int iCountTwo = s2.length(); 
-   
- 	//set arrays to zero 
- 	for (int i = 0; i < 256; i++) 
- 	{ 
- 		countsA[i] = 0; 
- 		countsB[i] = 0; 
- 	} 
-   
- 	for (int j = 0; j < iCountOne; j++) 
- 	{ 
- 		countsA[j] = s1.at(j); 
- 	} 
-   
- 	int sumOne = 0; 
-   
- 	for (int k = 0; k < iCountOne; k++) 
- 	{ 
- 		sumOne += countsA[k]; 
- 	} 
-   
- 	for (int l = 0; l < iCountTwo; l++) 
- 	{ 
- 		countsB[l] = s2.at(l); 
- 	} 
-   
- 	int sumTwo = 0; 
-   
- 	for (int m = 0; m < iCountTwo; m++) 
- 	{ 
- 		sumTwo += countsB[m]; 
- 	} 
- 	if(sumOne == sumTwo) 
- 	{ 
- 		cout << "ANAGRAM"; 
- 		return true; 
- 	} 
- 	else  
- 	{ 
- 		cout << "NOT ANAGRAM"; 
- 		return false; 
- 	} 
- }