fork download
  1. #include<stdio.h>
  2. int main(void)
  3. {
  4. char array_word1[100]={'\0'}, array_word2[100]={'\0'} , array[26]={'\0'};
  5. char ch;
  6. int i=0 , j=0, count=0;
  7.  
  8. printf(" Enter first word: ");
  9.  
  10. while((ch=getchar())!='\n')
  11. {
  12. array_word1[j++]=ch;
  13. array[ch -'a']++;
  14. }
  15.  
  16. printf(" Enter second word: ");
  17.  
  18. while((ch=getchar())!='\n')
  19. {
  20. array_word2[j++]=ch;
  21. array[ch -'a']--;
  22. }
  23.  
  24.  
  25. for(i=0; i<26; i++)
  26. {
  27. if(array[i]!= 0)
  28. {
  29. count++;
  30. break;
  31. }
  32.  
  33. }
  34.  
  35. if(count)
  36. printf(" Two words are not anagrams ");
  37.  
  38. else
  39. printf(" Two words are anagrams ");
  40.  
  41.  
  42. return 0;
  43. }
  44. //----------------------------------------------------------------------
  45.  
Time limit exceeded #stdin #stdout 5s 1724KB
stdin
Standard input is empty
stdout
Standard output is empty