两边往中间搜
by 吾皇 @ 2019-07-17 21:22:47
或者把原字符串倒过来比较是否相同
by 吾皇 @ 2019-07-17 21:23:15
递归的话..
by 吾皇 @ 2019-07-17 21:23:42
@[ 吾皇](/space/show?uid=136601) 大佬大佬,停止条件是什么?
by 海无量 @ 2019-07-17 21:23:46
..递归的话应该是
```cpp
inline bool hw(string s){
if(s.size()<2) return true;
else if(s[0]!=s[s.size()-1]) return false;
else return hw(s.substr(1,s.size()-2));
}
```
吧
by 吾皇 @ 2019-07-17 21:36:45
两边往中间搜的话
```cpp
inline bool hw(string s){
int i=0,j=s.size()-1;
while(i<=j){
if(s[i]!=s[j]) return false;
i++,j--;
}
return true;
}
```
差不多
by 吾皇 @ 2019-07-17 21:39:38
感觉你用$size$算出整条的长度,根据选择的方式就可以直到边界了吧(逃
by renxiaoyu @ 2019-07-17 21:41:19
@[海无量](/space/show?uid=157800)
by renxiaoyu @ 2019-07-17 21:41:35
@[renxiaoyu](/space/show?uid=196949) 巨佬!
by 海无量 @ 2019-07-17 22:04:45
@[ 吾皇](/space/show?uid=136601) 谢谢大佬的程序!
by 海无量 @ 2019-07-17 22:05:23