[Pointers and C-String]D. Liang 7.18 Anagrams
Description:
Write a function that checks whether two words are anagrams. Two words are anagrams if they contain the same letters in any order. For example, “silent” and “listen” are anagrams. The header of the function is as follows:
int isAnagram(const char * const s1, const char * const s2)
Hint:
Don’t submit the main() function.
Programme:
//Date:2020/5/18
//Author:Kamenrider Justice
int isAnagram(const char * const s1, const char * const s2)
{
int i,j,flag=0;
for(i=0;i<strlen(s2);i++)
{
for(j=0;j<strlen(s1);j++)
{
if(s2[i]==s1[j])
{
flag++;
break;
}
}
if(flag==strlen(s2))
{
return 1;
}
}
return 0;
}
Redis 面试精讲