Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void sortowanie(string &d)
- {
- int n=d.size();
- for(int j=0;j<n-1;j++)
- for(int i=0;i<n-1-j;i++)
- if(d[i]>d[i+1])
- swap(d[i], d[i+1]);
- }
- int main()
- {
- string d,c;
- cout<<"Podaj pierwszy anagram(tylko male litery): "<<endl;
- cin>>d;
- cout<<"Podaj drugi anagram(tylko male litery): "<<endl;
- cin>>c;
- sortowanie(d);
- sortowanie(c);
- int dlc=c.size();
- int dld=d.size();
- if(dlc==dld)
- {
- for(int i=0;i<=dlc;i++)
- {
- if(d[i]!=c[i])
- {
- cout<<"To nie sa anagramy";
- return 0;
- }
- }
- }else
- {
- cout<<"To nie sa anagramy";
- return 0;
- }
- cout<<"To sa anagramy";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement