careercup4

/*Write a method to decide if two strings are anagrams or not
*/
#include <iostream>
#include <string>
using namespace std;


bool JudgeAnagrams(string s1, string s2){
int st1[256],st2[256];


if(s1.length() != s2.length())
return 0;


for(int i = 0; i< s1.length(); i++)
{
 st1[s1[i]]++;
 st2[s2[i]]++;
}


for(int i= 0; i<256; i++)
if(st1[i] != st2[i])
return 0;

   return 1;
}


int main(){
   string str1,str2;
   cin>>str1;
   cin>>str2;
 
   cout<<JudgeAnagrams(str1,str2)<<endl;
}





發佈了32 篇原創文章 · 獲贊 1 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章