Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <cctype>
- using namespace std;
- int main() {
- char *word = new char[200];
- int n;
- bool pal=true;
- cin >> n;
- cin.getline(word, 200);
- for (int i = 0; i < n; i++){
- cin.getline(word, 200);
- int w_len = strlen(word);
- pal = true;
- for (int j = 0, k = w_len - 2; j < (w_len - 1) / 2 && pal; j++, k--){
- if(tolower(word[j]) != tolower(word[k])){
- pal = false;
- break;
- }
- }
- if(pal){
- for (int j = 0; j < w_len - 1; j++){
- cout << word[j];
- }
- cout << " - to jest palindrom" << endl;
- }
- else{
- for (int j = 0; j < w_len - 1; j++){
- cout << word[j];
- }
- cout << " - to nie jest palindrom" << endl;
- }
- }
- delete[] word;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement