最长对称子串
题目思路代码回顾回文数
题目
思路
代码
#include<iostream>
using namespace std
;
int main(){
string s
;
getline(cin
,s
);
int maxvalue
=0;
int temp
;
int len
=s
.length();
for(int i
=0;i
<len
;i
++){
temp
=1;
for(int j
=1;j
<len
;j
++){
if(i
-j
<0||i
+j
>=len
||s
[i
-j
]!=s
[i
+j
])
break;
temp
+=2;
}
maxvalue
=temp
>maxvalue
?temp
:maxvalue
;
temp
=0;
for(int j
=1;j
<len
;j
++){
if(i
+1-j
<0||i
+j
>=len
||s
[i
+1-j
]!=s
[i
+j
])
break;
temp
+=2;
}
maxvalue
=temp
>maxvalue
?temp
:maxvalue
;
}
cout
<<maxvalue
;
return 0;
}
回顾回文数
判断回文数
转载请注明原文地址:https://blackberry.8miu.com/read-11499.html