#include<iostream> #include<algorithm> #include<memory.h> usingnamespace std; intPalindrome(const string &s){ int ret = 1; int len; for(int i=0;i<s.length()-1;i++){ len = 0; while((i-len-1)>=0&&(i+len+1<s.length()) && s[i-len-1]==s[i+len+1]) ++len; ret = ret > (len<<1)+1 ? ret : (len<<1)+1; if(s[i]!=s[i+1]) continue; len = 1; while((i-len)>=0&&(i+len+1<s.length()) && s[i-len]==s[i+1+len]) ++len; ret = ret > len<<1 ? ret : len<<1; } return ret; }
intmain(int argc, char** argv){ const string s = "BANANA"; cout<<Palindrome(s)<<endl; return0;//정상종료시 반드시 0을 리턴해야합니다. }