fork download
  1. #include <iostream>
  2. #include <map>
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5.  
  6. int main() {
  7. // your code goes here
  8. string a="Sodhi";
  9. string b="Rahul";
  10. int i=0,j;
  11. char c;
  12. while(a[i]){
  13. c=a[i];
  14. a[i]=tolower(c);
  15. i++;
  16. }
  17. i=0;
  18. while(b[i]){
  19. c=b[i];
  20. b[i]=tolower(c);
  21. i++;
  22. }
  23. if(a.length()==b.length()){
  24. int f;
  25. for(i=0;i<a.length();i++){
  26. f=0;
  27. for(j=0;j<b.length();j++){
  28. if(a[i]==b[j])
  29. f=1;
  30.  
  31. }
  32. if(f==0){
  33. cout<<"Not anagram";
  34. break;
  35. }
  36. }
  37. if(f==1)
  38. {
  39. cout<<"Yes anagram"<<endl;
  40. }
  41. }
  42. else{
  43. cout<<"Not anagram"<<endl;
  44. }
  45. return 0;
  46. }
Success #stdin #stdout 0s 4492KB
stdin
Standard input is empty
stdout
Not anagram