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