题解 | #最长回文子串#
最长回文子串
https://www.nowcoder.com/practice/12e081cd10ee4794a2bd70c7d68f5507
#include<stdio.h>
#include<string.h>
int main(){
char str1[350],str2[350];
scanf("%s",str1);
int max=0;
for(int i=0;i<strlen(str1)-1;i++){//此处i是左端点
for(int j=i+1;j<strlen(str1);j++){
int l=i,r=j;
while(l<r){
if(str1[r]!=str1[l])break;
else{l++;r--;}
}
if(l>=r){
max=(max>(j-i+1))?max:(j-i+1);
}
}
}
printf("%d",max);
}
#华为OD机考#


