回文子串

    xiaoxiao2021-03-25  89

    #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include <algorithm> using namespace std; int i,j,k,len; char s[1000]; int check(int st,int l) { int le,ri; le=st;ri=st+l-1; while (le<ri) if (s[le++]!=s[ri--]) return 0; return 1; } int main() { cin>>s; len=strlen(s); for (j=2;j<=len;++j){ for (i=0;i<len-j+1;++i) if (check(i,j)){ for (k=i;k<=i+j-1;++k) cout<<s[k]; cout<<endl; } } return 0; }
    转载请注明原文地址: https://ju.6miu.com/read-26562.html

    最新回复(0)