Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- int pewnosc=0;
- string wyraz;
- cout<<"Podaj wraz do odwrocenia:";
- cin>>wyraz;
- int dlugosc = wyraz.length();
- for(int i=dlugosc-1; i>=0; i--)
- {
- cout<<wyraz[i];
- }
- cout<<endl;
- cout<<endl;
- for (int i=0; i<(dlugosc-1)/2; i++)
- {
- if (wyraz[i] == wyraz[dlugosc-(i+1)])
- {
- pewnosc=pewnosc+1;
- }
- else
- {
- }
- }
- if(pewnosc == (dlugosc-1)/2)
- {
- cout<<"To jest palindrom"<<endl;
- }
- else
- {
- cout<<"To nie jest palindrom"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement