解题思路:
1、先将字符串插入;
2、判断回文,并统计次数。
#include <iostream>
#include<string>
using namespace std;
bool IsCircle(const string &s){
int begin=0;
int end=s.size()-1;
while(begin<end){
if(s[begin]!=s[end]){
return false;
}
++begin;
--end;
}
return true;
}
int main() {
string str1,str2;
getline(cin,str1);
getline(cin,str2);
int count=0;
for(int i=0;i<=str1.size();++i){
string str=str1;
str.insert(i,str2);
if(IsCircle(str)){
++count;
}
}
cout<<count<<endl;
return 0;
}
// 64 位输出请用 printf("%lld")

京公网安备 11010502036488号