1dop

 avatar
user_1041599
c_cpp
a month ago
901 B
1
Indexable
2kolok_SP
#include <iostream>
#include <cctype>
#include <cstring>
#include <iomanip>
using namespace std;

bool isPalindrome(char* s, int len) {
    int start = 0, end = len - 1;
    while (start < end) {
        if (s[start]!=s[end])
            return false;
        start++;
        end--;
    }
    return true;
}
bool specialChar(char* s, int len) {
    for (int i = 0; i < len; i++) {
        if (!isalnum(s[i]))
            return true;
    }
    return false;
}

int main() {
    int n;
    cin>>n;
    cin.ignore();
    char s[81];
    int maxLen = 0;
    char max[81];
    for(int i=0;i<n;i++) {
        cin.getline(s,81);
        int len = strlen(s);
        //cout<<len<<endl;
        if (isPalindrome(s,len) and specialChar(s,len) and len>maxLen) {
            maxLen = len;
            strcpy(max,s);
        }
    }
    if (maxLen == 0)
        cout<<"Nema!";
    else
        cout<<max<<endl;
}
Leave a Comment