Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
136429 hjx455 统计回文子串 C++ Accepted 130 MS 280 KB 478 2025-11-14 12:33:58

Tests(1/1):


Code:

#include <bits/stdc++.h> using namespace std; int main() { char s[5050]; int i,j,l; while (cin>>s) { l=strlen(s); int k=0; for (i=0;i<l;i++) { for (j=0;i-j>=0 and i+j<l;j++) //奇数aaa { if (s[i-j]==s[i+j]) k++; else break; } if (s[i]==s[i+1]) for (j=0;i-j>=0 && i+1+j<l;j++) //偶数 { if (s[i-j]==s[i+1+j]) k++; else break; } } cout<<k<<endl; } return 0; }