Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int Anagram_Check( char X[] , char Y[] )
- {
- int i , j;
- int length_y = 0 , length_x = 0;
- i = 0;
- j = 0;
- while ( X[i] != '\0' )
- length_x ++ , i ++ ;
- while ( Y[j] != '\0' )
- length_y ++ , j ++ ;
- i = 0;
- j = 0;
- while (i < length_y)
- {
- while (j < length_x)
- {
- if ( Y[i] == X[j] )
- {
- X[j] = '-' ;
- break ;
- }
- j++;
- }
- if ( j == length_x ) return 0 ;
- i ++;
- }
- i = 0;
- while (i < length_x)
- {
- if ( X[i] != '-' ) return 0 ;
- i++;
- }
- return 1 ;
- }
- int main()
- {
- char X[] = "tea" ;
- char Y[] = "eat" ;
- printf("%d",Anagram_Check(X,Y));
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement