• Source
    1. #include <iostream>
    2. #include <string>
    3.  
    4.  
    5. using namespace std;
    6.  
    7. int main()
    8. {
    9. string s1, s2 ;
    10. int dl1, dl2, pom, pom1, T1[2]={0,0}, T2[2]={0,0} ;
    11. cout << "Podaj wyraz: ";
    12. cin >> s1;
    13. cout << "Podaj wyraz: ";
    14. cin >> s2;
    15. dl1 = s1.size();
    16. dl2 = s2.size();
    17. if (dl1!=dl2) { cout << "NIE SA" << endl; }
    18. else
    19. {
    20.  
    21. for (int i=0; i<dl1; i++)
    22. {
    23. pom = (int)s1[i];
    24. T1[pom-88]++;
    25. pom = (int)s2[i];
    26. T2[pom-88]++;
    27. }
    28.  
    29.  
    30. for (int i=0; i<2; i++)
    31. {
    32. if ( T1[i]!=T2[i]) {pom=1; break; }
    33. }
    34.  
    35. if (pom==1) { cout << "nie jest" <<endl; }
    36. else {cout << "jest anagramem" <<endl; }
    37. }
    38.  
    39. return 0;
    40. }