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 slowo;
- int pomoc=0;
- cout << "podaj slowo do sprawdzenia(z malej litery)"<< endl;
- cin>>slowo;
- int dl=slowo.size();
- sortowanie(slowo);
- for(int i=0;dl>i;)
- {
- if(slowo[i]==slowo[i+1])
- {
- i+=2;
- }else
- {
- pomoc++;
- i++;
- //cout<<endl<<pomoc<<endl; //DO SPRAWDZENIA ILOŚCI LITER BEZ PAR JEŻELI WIĘCEJ NIŻ 1 TO NIE PALIDROM
- }
- }
- //cout<<endl<<endl<<slowo<<endl; //ABY WYŚWIELTIĆ SŁOWO PO POSORTOWANIU
- if(pomoc==1||pomoc==0)
- cout<<"to jest palindrom";
- else
- cout<<"To nie jest palindrom";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement