Write a function that tests whether two words or phrases are anagrams (permutations of the same letters):
寫一個判斷兩個單詞或詞組是不是符合易位構詞的函數。
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int is_anagrams(char A[],char B[])
{
/*INSERT YOUR CODE HERE*/
/*END OF YOUR CODE*/
//The function should return 1 if two words or phrases are anagrams, 0 if two words or phrases are not anagrams.
}
int main(void)
{
char A[100],B[100];
/*INSERT YOUR CODE HERE*/
/*END OF YOUR CODE*/
if (is_anagrams(A,B)) printf("Two words or phrases are anagrams");
else printf("Two words or phrases are not anagrams");
return 0;
}
Example input:
smartest
mattress
Example output:
Two words or phrases are anagrams
Example input:
dumbest
stumble
Example output:
Two words or phrases are not anagrams
Remember: You may correct the cases, but your code always be revised!