Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- string wyraz;
- cout<<"podaj wyraz: ";
- cin>>wyraz;
- int dlugosc= wyraz.length();
- bool warunek;
- int j=0;
- int i=dlugosc-1;
- for(int z=dlugosc/2;z>0;z--)
- {
- if(wyraz[j]==wyraz[i])
- {
- warunek=true;
- }
- else
- {
- warunek=false;
- break;
- }
- j++;
- i--;
- }
- if(warunek==true)
- cout<<"jest palindromem"<<endl;
- else
- cout<<"nie jest palindromem"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement