/*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; }
careercup4
最新推荐文章于 2014-06-11 19:28:00 发布