Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main ()
- {
- char string1[100];
- char string2[100];
- int i,test=0;
- int calstr1[26]={0},calstr2[26]={0};
- scanf("%s",string1);
- scanf("%s",string2);
- for (i=0; string1[i]!='\0' ;i++)
- {
- calstr1[string1[i]-'a']++;
- }
- for (i=0; string2[i]!='\0' ;i++)
- {
- calstr2[string2[i]-'a']++;
- }
- for (i=0;i<=25;i++)
- {
- if (calstr1[i] !=calstr2[i])
- test = 1;
- }
- if(test==0)
- printf("'%s' and '%s' are anagrams.\n",string1,string2);
- else
- printf("'%s' and '%s' are not anagrams.\n",string1,string2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment