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 , length_y = 0 , length_x = 0 , j ;
- int k = 0 , l = 0;
- while ( X[k] != '\0' )
- {
- length_x ++;
- k ++ ;
- }
- while ( Y[l] != '\0' )
- {
- length_y ++;
- l ++ ;
- }
- for ( i = 0 ; i < length_y ; i ++ )
- {
- for ( j = 0 ; j < length_x ; j ++ )
- if ( Y[i] == X[j] )
- {
- X[j] = '-' ;
- break ;
- }
- if ( j == length_x ) return 0 ;
- }
- for ( i = 0 ; i < length_x ; i ++ )
- if ( X[i] != '-' ) return 0 ;
- return 1 ;
- }
- int main()
- {
- char X[1000];
- char Y[1000];
- gets(X);
- gets(Y);
- printf("%d",Anagram_Check(X,Y));
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement