Welcome~~~


Another blog:
http://fun-st.blogspot.com/

It is easier to write an incorrect program than understand a correct one.

Friday, April 1, 2011

#Two strings,find out they are anagrams

If two strings s1 and s2 are given find out they are anagrams are not "abc" and "bca' are string anagrams characters will be same in both but order may change

int findAna(char *s1, char*s2){
int sum = 0;
while(*s1 != '\0')
sum ^= *s1++;
while(*s2 != '\0')
sum ^= *s2++;
return sum;
void main (){
int i;
i = findAna("abcd","bac");
printf("%d",i); // i = 0 ? => anagrams .... else not anagrams :)
}

--

♥ ¸¸.•*¨*•♫♪♪♫•*¨*•.¸¸♥

No comments:

Post a Comment