首页
IT
登录
6mi
u
盘
搜
搜 索
IT
回文子串
回文子串
xiaoxiao
2021-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
)